Sha256: eac6b25c47ffb4e54ae3df0507b22f12f3addb8317bd463f7befef323a92235a

Contents?: true

Size: 264 Bytes

Versions: 29

Compression:

Stored size: 264 Bytes

Contents

# Add ordinal method to Numeric class
class Numeric
  def ordinal
    cardinal = self.to_i.abs
    if (10...20).include?(cardinal) then
      cardinal.to_s << 'th'
    else
      cardinal.to_s << %w{th st nd rd th th th th th th}[cardinal % 10]
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
tournament-5.0.0 webgui/config/initializers/ordinal.rb
tournament-4.2.0 webgui/config/initializers/ordinal.rb
tournament-4.0.2 webgui/config/initializers/ordinal.rb
tournament-4.0.0 webgui/config/initializers/ordinal.rb
tournament-3.3.3 webgui/config/initializers/ordinal.rb
tournament-3.3.2 webgui/config/initializers/ordinal.rb
tournament-3.3.1 webgui/config/initializers/ordinal.rb
tournament-3.3.0 webgui/config/initializers/ordinal.rb
tournament-3.2.2 webgui/config/initializers/ordinal.rb
tournament-3.2.1 webgui/config/initializers/ordinal.rb
tournament-3.2.0 webgui/config/initializers/ordinal.rb
tournament-3.1.1 webgui/config/initializers/ordinal.rb
tournament-3.1.0 webgui/config/initializers/ordinal.rb
tournament-3.0.3 webgui/config/initializers/ordinal.rb
tournament-3.0.2 webgui/config/initializers/ordinal.rb
tournament-3.0.1 webgui/config/initializers/ordinal.rb
tournament-3.0.0 webgui/config/initializers/ordinal.rb
tournament-2.1.1 webgui/config/initializers/ordinal.rb
tournament-2.1.2 webgui/config/initializers/ordinal.rb
tournament-2.1.0 webgui/config/initializers/ordinal.rb