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-2.4.3 lib/core/facets/integer/ordinal.rb
facets-2.4.2 lib/core/facets/integer/ordinal.rb
facets-2.4.5 lib/core/facets/integer/ordinal.rb
facets-2.5.1 lib/core/facets/integer/ordinal.rb
facets-2.5.0 lib/core/facets/integer/ordinal.rb
facets-2.5.2 lib/core/facets/integer/ordinal.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/integer/ordinal.rb