Sha256: b656ba091044f68ccbf196d04749a70b663c0522d3cb7e98a3ea7eccdecf1d6a

Contents?: true

Size: 615 Bytes

Versions: 20

Compression:

Stored size: 615 Bytes

Contents

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

class String
  def slugize
    self.downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '')
  end

  def humanize
    self.capitalize.gsub(/[-_]+/, ' ')
  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

20 entries across 20 versions & 3 rubygems

Version Path
ceilingfish-toto-0.4.5 lib/ext/ext.rb
toto-0.4.2 lib/ext/ext.rb
ceilingfish-toto-0.4.4 lib/ext/ext.rb
ceilingfish-toto-0.4.3 lib/ext/ext.rb
ceilingfish-toto-0.4.2 lib/ext/ext.rb
ceilingfish-toto-0.4.0 lib/ext/ext.rb
toto-0.4.1 lib/ext/ext.rb
toto-0.4.0 lib/ext/ext.rb
ceilingfish-toto-0.3.9 lib/ext/ext.rb
ceilingfish-toto-0.3.8 lib/ext/ext.rb
ceilingfish-toto-0.3.7 lib/ext/ext.rb
toto-0.3.3 lib/ext/ext.rb
ceilingfish-toto-0.3.5 lib/ceilingfish/ext/ext.rb
ceilingfish-toto-0.3.4 lib/ceilingfish/ext/ext.rb
toto-haml-0.3.3 lib/ext/ext.rb
toto-haml-0.3.2 lib/ext/ext.rb
toto-0.3.2 lib/ext/ext.rb
toto-0.3.1 lib/ext/ext.rb
toto-0.3.0 lib/ext/ext.rb
toto-0.2.8 lib/ext/ext.rb