File tree 2 files changed +50
-2
lines changed
2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ require 'csv'
2
+
3
+ path_to_csv = '../../bin/birthday_data.csv'
4
+ if ENV [ 'DEV' ]
5
+ path_to_csv = './bin/birthday_data.csv'
6
+ end
7
+
8
+ puts "Please type a name"
9
+ name = gets . chomp . capitalize
10
+
11
+ spreadsheet = CSV . read ( path_to_csv , headers :true )
12
+
13
+ for x in 0 ...spreadsheet . length
14
+ if spreadsheet [ x ] [ 0 ] == name || spreadsheet [ x ] [ 1 ] == name
15
+ place = x
16
+ end
17
+ end
18
+
19
+ birthday = spreadsheet [ place ] [ 2 ] . split ( '/' )
20
+ age = 2014 - Integer ( birthday [ 0 ] )
21
+
22
+ if birthday [ 1 ] == "01"
23
+ print "January "
24
+ elsif birthday [ 1 ] == "02"
25
+ print "February "
26
+ elsif birthday [ 1 ] == "03"
27
+ print "March "
28
+ elsif birthday [ 1 ] == "04"
29
+ print "April "
30
+ elsif birthday [ 1 ] == "05"
31
+ print "May "
32
+ elsif birthday [ 1 ] == "06"
33
+ print "June "
34
+ elsif birthday [ 1 ] == "07"
35
+ print "July "
36
+ elsif birthday [ 1 ] == "08"
37
+ print "August "
38
+ elsif birthday [ 1 ] == "09"
39
+ print "September "
40
+ elsif birthday [ 1 ] == "10"
41
+ print "October "
42
+ elsif birthday [ 1 ] == "11"
43
+ print "November "
44
+ elsif birthday [ 1 ] == "12"
45
+ print "December "
46
+ end
47
+
48
+ print "#{ Integer ( birthday [ 2 ] ) } , #{ birthday [ 0 ] } ,
49
+ #{ age } years old"
50
+
Original file line number Diff line number Diff line change 2
2
3
3
describe "BirthdayHelper" do
4
4
it "returns the birth date and age of the first name typed in" do
5
- pending
6
5
run_script ( "birthday_helper.rb" )
7
6
type ( "Mike" )
8
7
13
12
end
14
13
15
14
it "returns the birth date and age of the last name typed in" do
16
- pending
17
15
run_script ( "birthday_helper.rb" )
18
16
type ( "Dean" )
19
17
You can’t perform that action at this time.
0 commit comments