Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created November 21, 2011 19:52
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 austinbv/1383724 to your computer and use it in GitHub Desktop.
Save austinbv/1383724 to your computer and use it in GitHub Desktop.
class Integer
def place
case self % 10
when 1
"#{self}st"
when 2
"#{self}nd"
when 3
"#{self}rd"
when 4..9, 0
"#{self}th"
end
end
end
(1..100).each do |x|
puts x.place
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment