Sha256: 97bda32041d48cda9d21b5486fd4878b724d5b97e8f1102e90a00caf86a06fbe

Contents?: true

Size: 232 Bytes

Versions: 8

Compression:

Stored size: 232 Bytes

Contents

class String
  def underscore
    word = self.to_s.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

8 entries across 8 versions & 1 rubygems

Version Path
rescpos-0.0.9 lib/core_ext/string.rb
rescpos-0.0.8 lib/core_ext/string.rb
rescpos-0.0.7 lib/core_ext/string.rb
rescpos-0.0.6 lib/core_ext/string.rb
rescpos-0.0.5 lib/core_ext/string.rb
rescpos-0.0.3 lib/core_ext/string.rb
rescpos-0.0.2 lib/core_ext/string.rb
rescpos-0.0.1 lib/core_ext/string.rb