Skip to content

Instantly share code, notes, and snippets.

@mblythe86
mblythe86 / fixnum_ordinalize.rb
Last active March 9, 2016 20:11 — forked from alterisian/fixnum_ordinalize.rb
Adds ordinalize i.e. th,st,rd to a number for use in date string outputs
class Fixnum
def ordinal
abs_number = self.abs
if (11..13).include?(abs_number % 100)
"th"
else
case abs_number % 10
when 1; "st"
when 2; "nd"
when 3; "rd"