Introduction to Ruby
• Ruby is a scripting language
• Famous for rails
• Intended as a followup to Perl
• Japanese in origin
• Goal was to make
programming fun again
Wednesday, March 14, 12
Slide 3
Slide 3 text
Enough Description,
Let’s see some ruby!
Wednesday, March 14, 12
Slide 4
Slide 4 text
Hello, World!
Wednesday, March 14, 12
Slide 5
Slide 5 text
Hello, World!
Wednesday, March 14, 12
Slide 6
Slide 6 text
Hello, World!
Wednesday, March 14, 12
Slide 7
Slide 7 text
Let’s personalize it!
Wednesday, March 14, 12
Slide 8
Slide 8 text
Let’s personalize it!
Wednesday, March 14, 12
Slide 9
Slide 9 text
what is “chomp”?
\n
B e n
Wednesday, March 14, 12
Slide 10
Slide 10 text
what is “chomp”?
B e n
Wednesday, March 14, 12
Slide 11
Slide 11 text
what is “chomp”?
Wednesday, March 14, 12
Slide 12
Slide 12 text
what is “chomp”?
Wednesday, March 14, 12
Slide 13
Slide 13 text
What about numbers?
Wednesday, March 14, 12
Slide 14
Slide 14 text
What about numbers?
Wednesday, March 14, 12
Slide 15
Slide 15 text
What about numbers?
Wednesday, March 14, 12
Slide 16
Slide 16 text
How about a File instead?
Wednesday, March 14, 12
Slide 17
Slide 17 text
How about a File instead?
Wednesday, March 14, 12
Slide 18
Slide 18 text
How about a File instead?
Wednesday, March 14, 12
Slide 19
Slide 19 text
How about a File instead?
Wednesday, March 14, 12
Slide 20
Slide 20 text
How about a File instead?
Wednesday, March 14, 12
Slide 21
Slide 21 text
How about a File instead?
Wednesday, March 14, 12
Slide 22
Slide 22 text
Now something useful
Wednesday, March 14, 12
Slide 23
Slide 23 text
Now something useful
Wednesday, March 14, 12
Slide 24
Slide 24 text
How split works
B e n N i c h o l a s
Wednesday, March 14, 12
Slide 25
Slide 25 text
How split works
B e n N i c h o l a s
,
Wednesday, March 14, 12
Slide 26
Slide 26 text
Now something useful
Wednesday, March 14, 12
Slide 27
Slide 27 text
Now something useful
Wednesday, March 14, 12
Slide 28
Slide 28 text
pretend it’s a gradebook
Wednesday, March 14, 12
Slide 29
Slide 29 text
pretend it’s a gradebook
Wednesday, March 14, 12
Slide 30
Slide 30 text
pretend it’s a gradebook
Wednesday, March 14, 12
Slide 31
Slide 31 text
Computers can do Math?
Wednesday, March 14, 12
Slide 32
Slide 32 text
Computers can do Math?
Wednesday, March 14, 12
Slide 33
Slide 33 text
How Map Works
“100” “90” “80”
grades:
Wednesday, March 14, 12
Slide 34
Slide 34 text
How Map Works
“100” “90” “80”
grades:
int_grades:
Wednesday, March 14, 12
Slide 35
Slide 35 text
How Map Works
“100” “90” “80”
100
grades:
int_grades:
Wednesday, March 14, 12
Slide 36
Slide 36 text
How Map Works
“100” “90” “80”
100 90
grades:
int_grades:
Wednesday, March 14, 12
Slide 37
Slide 37 text
How Map Works
“100” “90” “80”
100 90 80
grades:
int_grades:
Wednesday, March 14, 12
Slide 38
Slide 38 text
How reduce works
100 90 80
total: 0
grade: 100
Wednesday, March 14, 12
Slide 39
Slide 39 text
How reduce works
100 90 80
total: 100
grade: 90
Wednesday, March 14, 12
Slide 40
Slide 40 text
How reduce works
100 90 80
total: 190
grade: 80
Wednesday, March 14, 12