Sha256: e3935412b9cf71513c1f4a49e291d00abd20313866c762693bb013f60a0b3625

Contents?: true

Size: 866 Bytes

Versions: 7

Compression:

Stored size: 866 Bytes

Contents

class Fixnum

  # todo: complete
  def human_ordinalize(map={})
    map.key?(self) ? map[self] : (begin
      if self < -1
        "#{(-self).human_ordinalize} to last"
      else
        case self
        when -1;  "last"
        when 1;   "first"
        when 2;   "second"
        when 3;   "third"
        when 4;   "fourth"
        when 5;   "fifth"
        when 6;   "sixth"
        when 7;   "seventh"
        when 8;   "eighth"
        when 9;   "ninth"
        when 10;  "tenth"
        when 11;  "eleventh"
        when 12;  "twelfth"
        when 13;  "thirteenth"
        when 14;  "fourteenth"
        when 15;  "fifteenth"
        when 16;  "sixteenth"
        when 17;  "seventeeth"
        when 18;  "eighteenth"
        when 19;  "nineteenth"
        when 20;  "twentieth"
        else;     self.ordinalize
        end
      end
    end)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hiccup-0.6.0 lib/hiccup/core_ext/fixnum.rb
hiccup-0.5.20 lib/hiccup/core_ext/fixnum.rb
hiccup-0.5.19 lib/hiccup/core_ext/fixnum.rb
hiccup-0.5.18 lib/hiccup/core_ext/fixnum.rb
hiccup-0.5.17 lib/hiccup/core_ext/fixnum.rb
hiccup-0.5.16 lib/hiccup/core_ext/fixnum.rb
hiccup-0.5.15 lib/hiccup/core_ext/fixnum.rb