Sha256: 4ac80709dba7ea7f4e83cf748374dd0ffbd630e293df1cd6f448ea8c274f17e5

Contents?: true

Size: 441 Bytes

Versions: 15

Compression:

Stored size: 441 Bytes

Contents

class Object
  def meta_def name, &blk
    (class << self; self; end).instance_eval do
      define_method(name, &blk)
    end
  end
end

class Fixnum
  def ordinal
    # 1 => 1st
    # 2 => 2nd
    # 3 => 3rd
    # ...
    case self % 100
      when 11..13; "#{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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
toto-0.2.7 lib/ext.rb
toto-0.2.6 lib/ext.rb
toto-0.2.5 lib/ext.rb
toto-0.2.4 lib/ext.rb
toto-0.2.3 lib/ext.rb
toto-0.2.2 lib/ext.rb
toto-0.2.1 lib/ext.rb
toto-0.2.0 lib/ext.rb
toto-0.1.6 lib/ext.rb
toto-0.1.5 lib/ext.rb
toto-0.1.4 lib/ext.rb
toto-0.1.3 lib/ext.rb
toto-0.1.2 lib/ext.rb
toto-0.1.1 lib/ext.rb
toto-0.1.0 lib/ext.rb