Skip to content

Instantly share code, notes, and snippets.

@geelen
Forked from benhoskings/gist:36955
Created December 17, 2008 06:18
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 geelen/36960 to your computer and use it in GitHub Desktop.
Save geelen/36960 to your computer and use it in GitHub Desktop.
undefined
def number_to_ordinal num
int = num.to_i
int.to_s + ((10...20) === int) ? "th" : (%w{th st nd rd}[int % 10] or "th")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment