Class: Fixnum

Inherits:
Object show all
Defined in:
lib/zwite/ext/fixnum.rb

Instance Method Summary collapse

Instance Method Details

#ordinalizeObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/zwite/ext/fixnum.rb', line 3

def ordinalize
  if (11..13).include?(self.abs % 100)
    "#{self}th"
  else
    case self.abs % 10
      when 1; "#{self}st"
      when 2; "#{self}nd"
      when 3; "#{self}rd"
      else    "#{self}th"
    end
  end
end