Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/mode7date.rb

Instance Method Summary collapse

Instance Method Details

#ordinalizeObject

Via ActiveSupport’s Fixnum#ordinalize



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mode7date.rb', line 6

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