Class: Fixnum
Instance Method Summary collapse
Instance Method Details
#ordinal ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ext/ext.rb', line 31 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 |