Class: Integer
Instance Method Summary collapse
Instance Method Details
#ordinalize ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/zwite/ext/integer.rb', line 3 def ordinalize if (11..13).include?(self.abs % 100) "#{self}th" else case self.abs % 10 when 1; "#{self}st" when 2; "#{self}nd" when 3; "#{self}rd" else "#{self}th" end end end |