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