-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcept
More file actions
executable file
·86 lines (69 loc) · 1.89 KB
/
concept
File metadata and controls
executable file
·86 lines (69 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env ruby
# A version of conception connection written in ruby
# Soon to be ported to rails, hopefully
require 'rubygems'
require 'curb'
require 'curb-fu'
require 'date'
def main
s = "(no leading zeros): "
print "Input your birth year (yyyy): "
year = Integer(gets.chomp)
print "Enter your birth month as a number #{s}"
month = Integer(gets.chomp)
print "Enter your birth day as a number #{s}"
day = Integer(gets.chomp)
unless month <= 12 && month >= 1
puts "Not a valid month"
return
end
con = (Date.new(year, month, day) - 266)
new_month = month_conversion(con.month)
rest = "#{con.year}/#{new_month}/#{con.day}"
date = "#{new_month}, #{day} #{year}".capitalize!
req = Curl.get("http://www.historyorb.com/date/" + rest)
result = req.body_str
index1 = result.index("</h2>")
index2 = result.index("<p>-", index1) + 5
index3 = result.index("<", index2) - 1
if index2 == -1
print "Nothing found"
else
event = result[index2..index3]
puts ""
puts "Your approximate conception date was " + date
puts "The event most likely to have cause your conception is..."
puts event
end
return
end
def month_conversion(new_month)
if new_month == 1
return "january"
elsif new_month == 2
return "february"
elsif new_month == 3
return "march"
elsif new_month == 4
return "april"
elsif new_month == 5
return "may"
elsif new_month == 6
return "june"
elsif new_month == 7
return "july"
elsif new_month == 8
return "august"
elsif new_month == 9
return "september"
elsif new_month == 10
return "october"
elsif new_month == 11
return "november"
elsif new_month == 12
return "december"
else
return "not valid"
end
end
main