require ‘rubygems’
require ‘linguistics’
Linguistics::use( :en, :installProxy => :en )
nouns = ["Partridge","Dove","Hen","Bird","Ring","Goose","Swan","Maid","Lady",
"Lord","Piper","Drummer"]
verbs = ["pear tree!","Turtle","French","Calling","Gold","a-Laying","a-Swimming","a-Milking","Dancing","a-Leaping","Piping","Drumming"]
(1..12).each do |day|
puts "On the #{day.ordinate} day of Christmas, my true love gave to me…"
day.times do |num|
count = day-num
noun = nouns[count-1].plural(count)
verb = verbs[count-1]
if count == 1
if day == 1
puts "#{noun.a.capitalize} in a #{verb}"
else
puts "And #{noun.a} in a #{verb}"
end
else if count > 5
puts "#{count.numwords.capitalize} #{noun} #{verb},"
else
puts "#{count.numwords.capitalize} #{verb} #{noun},"
end
end
end
puts ‘’
end
- – -
$ ruby christmas.rbOn the first day of Christmas, my true love gave to me…
A partridge in a pear tree!On the second day of Christmas, my true love gave to me…
Two Turtle Doves,
And a Partridge in a pear tree!On the third day of Christmas, my true love gave to me…
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the fourth day of Christmas, my true love gave to me…
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the fifth day of Christmas, my true love gave to me…
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the sixth day of Christmas, my true love gave to me…
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the seventh day of Christmas, my true love gave to me…
Seven Swans a-Swimming,
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the eighth day of Christmas, my true love gave to me…
Eight Maids a-Milking,
Seven Swans a-Swimming,
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the ninth day of Christmas, my true love gave to me…
Nine Ladys Dancing,
Eight Maids a-Milking,
Seven Swans a-Swimming,
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the tenth day of Christmas, my true love gave to me…
Ten Lords a-Leaping,
Nine Ladys Dancing,
Eight Maids a-Milking,
Seven Swans a-Swimming,
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the eleventh day of Christmas, my true love gave to me…
Eleven Pipers Piping,
Ten Lords a-Leaping,
Nine Ladys Dancing,
Eight Maids a-Milking,
Seven Swans a-Swimming,
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!On the twelfth day of Christmas, my true love gave to me…
Twelve Drummers Drumming,
Eleven Pipers Piping,
Ten Lords a-Leaping,
Nine Ladys Dancing,
Eight Maids a-Milking,
Seven Swans a-Swimming,
Six Geese a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves,
And a Partridge in a pear tree!
I’ll get me coat…

JuliaM
December 1, 2009 at 10:19 am