Sha256: 1f7d000a595fa9d0d9b0564e578e9105fbc99039c44cb3942efd755a2827f7f3

Contents?: true

Size: 893 Bytes

Versions: 15

Compression:

Stored size: 893 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

class Date
  # This check is for people running Toto with ActiveSupport, avoid a collision
  unless respond_to? :iso8601
    # Return the date as a String formatted according to ISO 8601.
    def iso8601
      ::Time.utc(year, month, day, 0, 0, 0, 0).iso8601
    end
  end
end

Version data entries

15 entries across 15 versions & 6 rubygems

Version Path
toto-0.4.9 lib/ext/ext.rb
toto-0.4.8 lib/ext/ext.rb
toto-0.4.7 lib/ext/ext.rb
allegro-0.0.0pre3 lib/allegro/ext/ext.rb
allegro-0.0.0pre2 lib/allegro/ext/ext.rb
allegro-0.0.0pre1 lib/allegro/ext/ext.rb
allegro-0.0.0pre lib/allegro/ext/ext.rb
robb-toto-0.4.6.1 lib/ext/ext.rb
toto_prerelease-0.4.7prerelease lib/ext/ext.rb
toto-0.4.6 lib/ext/ext.rb
cartera-toto-0.4.5 lib/ext/ext.rb
toto-0.4.5 lib/ext/ext.rb
toto-0.4.4 lib/ext/ext.rb
brad-toto-0.4.3 lib/ext/ext.rb
toto-0.4.3 lib/ext/ext.rb