
class Integer

  def ordinal
    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

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCInteger < Test::Unit::TestCase

    def test_ordinal
      assert_equal( '1st', 1.ordinal )
      assert_equal( '2nd', 2.ordinal )
      assert_equal( '3rd', 3.ordinal )
      assert_equal( '4th', 4.ordinal )
    end

  end

=end
