Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/cortex_reaver/snippets/numeric.rb
Instance Method Summary collapse
-
#ordinal ⇒ Object
Returns a -th, -nd, …
Instance Method Details
#ordinal ⇒ Object
Returns a -th, -nd, … string
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/cortex_reaver/snippets/numeric.rb', line 3 def ordinal if (11..13).include?(self.to_i % 100) "#{self}th" else case self.to_i % 10 when 1; "#{self}st" when 2; "#{self}nd" when 3; "#{self}rd" else "#{self}th" end end end |