Top Level Namespace

Defined Under Namespace

Modules: Boolean, Rubype Classes: Any, Method, Module

Instance Method Summary collapse

Instance Method Details

#ordinal(number) ⇒ Object

Borrowed from ActiveSupport::Inflector



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rubype/ordinal.rb', line 2

def ordinal(number)
  if (11..13).include?(number % 100)
    "th"
  else
    case number % 10
      when 1; "st"
      when 2; "nd"
      when 3; "rd"
      else    "th"
    end
  end
end