Class: Fixnum
Instance Method Summary collapse
Instance Method Details
#ordinal ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ext/ext.rb', line 20 def ordinal # 1 => 1st # 2 => 2nd # 3 => 3rd # ... case self % 100 when 11..13; "#{self}th" else case self % 10 when 1; "#{self}st" when 2; "#{self}nd" when 3; "#{self}rd" else "#{self}th" end end end |