Sha256: 9ed5ca07facb47cebdd2d4d6c5cf3ab1ea03f66a87f43531138c86a9011ba7f6

Contents?: true

Size: 828 Bytes

Versions: 19

Compression:

Stored size: 828 Bytes

Contents

class Hash
  def stringify_keys!
    keys.each do |key|
      self[key.to_s] = delete(key)
    end
    self
  end unless {}.respond_to?(:stringify_keys!)
end

class String
  def camelize
    dup.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
  end unless "".respond_to?(:camelize)

  def constantize
    names = self.split('::')
    names.shift if names.empty? || names.first.empty?

    constant = Object
    names.each do |name|
      constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
    end

    constant
  end unless "".respond_to?(:constantize)

  def underscore
    dup.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end unless "".respond_to?(:underscore)
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
frenchy-0.7.0 lib/frenchy/core_ext.rb
frenchy-0.6.3 lib/frenchy/core_ext.rb
frenchy-0.6.2 lib/frenchy/core_ext.rb
frenchy-0.6.1 lib/frenchy/core_ext.rb
frenchy-0.6.0 lib/frenchy/core_ext.rb
frenchy-0.5.2 lib/frenchy/core_ext.rb
frenchy-0.5.1 lib/frenchy/core_ext.rb
frenchy-0.5.0 lib/frenchy/core_ext.rb
frenchy-0.4.0 lib/frenchy/core_ext.rb
frenchy-0.3.0 lib/frenchy/core_ext.rb
frenchy-0.2.9 lib/frenchy/core_ext.rb
frenchy-0.2.8 lib/frenchy/core_ext.rb
frenchy-0.2.7 lib/frenchy/core_ext.rb
frenchy-0.2.6 lib/frenchy/core_ext.rb
frenchy-0.2.5 lib/frenchy/core_ext.rb
frenchy-0.2.4 lib/frenchy/core_ext.rb
frenchy-0.2.3 lib/frenchy/core_ext.rb
frenchy-0.2.2 lib/frenchy/core_ext.rb
frenchy-0.2.1 lib/frenchy/core_ext.rb