Method: Runt.ordinalize
- Defined in:
- lib/runt.rb
.ordinalize(number) ⇒ Object
Cut and pasted from activesupport-1.2.5/lib/inflector.rb
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/runt.rb', line 80 def ordinalize(number) if (number.to_i==-1) 'last' elsif (number.to_i==-2) 'second to last' elsif (11..13).include?(number.to_i % 100) "#{number}th" else case number.to_i%10 when 1 then "#{number}st" when 2 then "#{number}nd" when 3 then "#{number}rd" else "#{number}th" end end end |