Sha256: 7ff41591ddec59ccd60b1e6b34c8223f5009df13aa3b424879ce39391ea10616

Contents?: true

Size: 332 Bytes

Versions: 27

Compression:

Stored size: 332 Bytes

Contents

class Integer

  def ordinal
    if [11,12,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

  # Rails term.
  alias_method :ordinalize, :ordinal

end

Version data entries

27 entries across 26 versions & 3 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/integer/ordinal.rb
facets-3.1.0 lib/core/facets/integer/ordinal.rb
facets-3.0.0 lib/core/facets/integer/ordinal.rb
facets-2.9.3 lib/core/facets/integer/ordinal.rb
facets-2.9.2 src/core/facets/integer/ordinal.rb
facets-2.9.2 lib/core/facets/integer/ordinal.rb
facets-2.9.1 lib/core/facets/integer/ordinal.rb
facets-2.9.0 lib/core/facets/integer/ordinal.rb
facets-2.9.0.pre.2 lib/core/facets/integer/ordinal.rb
facets-2.9.0.pre.1 lib/core/facets/integer/ordinal.rb
facets-2.8.4 lib/core/facets/integer/ordinal.rb
facets-2.8.3 lib/core/facets/integer/ordinal.rb
facets-2.8.2 lib/core/facets/integer/ordinal.rb
facets-2.8.1 lib/core/facets/integer/ordinal.rb
facets-2.8.0 lib/core/facets/integer/ordinal.rb
facets-2.7.0 lib/core/facets/integer/ordinal.rb
facets-2.6.0 lib/core/facets/integer/ordinal.rb
facets-2.4.0 lib/facets/integer/ordinal.rb
facets-2.4.1 lib/facets/integer/ordinal.rb
facets-2.4.4 lib/core/facets/integer/ordinal.rb