Sha256: 597717dec591a79df68ac4437977e1eb0175fac911bd65421d6c1c6a8a3a9ac8

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

class String
  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
  def underscore
    gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end unless method_defined? :underscore

  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html]
  def demodulize
    gsub(/^.*::/, '')
  end unless method_defined? :demodulize
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
googleajax-1.0.1 lib/googleajax/extensions/string.rb
googleajax-1.0.0 lib/googleajax/extensions/string.rb