class Integer
Add helper methods to Integer
Public Instance Methods
ordinalize()
click to toggle source
Add ordinalize to simplify converting to spoken string
# File lib/githubchart.rb, line 100 def ordinalize return to_s if zero? return "#{self}th" if (11..13).cover?(abs % 100) case abs % 10 when 1 then "#{self}st" when 2 then "#{self}nd" when 3 then "#{self}rd" else "#{self}th" end end