Skip to content

Instantly share code, notes, and snippets.

@sheldonh
Created February 26, 2009 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheldonh/70827 to your computer and use it in GitHub Desktop.
Save sheldonh/70827 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class Geoff
def initialize(numeric = nil)
numeric ||= 1
@number = numeric.to_i
end
def to_s
["Geoff", title].join(" ")
end
private
def title
"the #{@number.ordinate}"
end
end
class Integer
def to_geoff
Geoff.new(self)
end
def ordinate
case self.to_s[-1,1]
when "1"
"#{self}st"
when "2"
"#{self}nd"
when "3"
"#{self}rd"
else
"#{self}th"
end
end
end
1.upto(10) do |generation|
puts generation.to_geoff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment