Class: PostFixr
- Inherits:
-
Object
- Object
- PostFixr
- Defined in:
- lib/number_postfixr.rb
Class Method Summary collapse
Class Method Details
.postfix(number) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/number_postfixr.rb', line 2 def self.postfix(number) fix = number.to_i.abs if (10...20).include?(fix) then fix.to_s << 'th' else fix.to_s << %w{th st nd rd th th th th th th}[fix % 10] end end |
.postfix_array(array) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/number_postfixr.rb', line 11 def self.postfix_array(array) fix = [] array.each do |elem| fix << postfix(elem) end return fix end |