Sha256: 297a3f2a6dc7f0cc442c6809fc6f5853e5df56ebb4ac530ccfb1f6c2c51db857

Contents?: true

Size: 332 Bytes

Versions: 6

Compression:

Stored size: 332 Bytes

Contents

# add method to String class
class String
  # add method :underscore for String class to convert Class name in camelcase
  def underscore
    word = dup
    word.gsub!(/::/, '/')
    word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
    word.tr!('-', '_')
    word.downcase!
    word
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
faat-0.1.7 lib/faat/helpers/string.rb
faat-0.1.6 lib/faat/helpers/string.rb
faat-0.1.5 lib/faat/helpers/string.rb
faat-0.1.4 lib/faat/helpers/string.rb
faat-0.1.3 lib/faat/helpers/string.rb
faat-0.1.1.beta lib/faat/support/string.rb