Sha256: a7ed3551f0138c011acebda97cba32ff40d70633b623d5c3380c3ca84a75002d

Contents?: true

Size: 272 Bytes

Versions: 4

Compression:

Stored size: 272 Bytes

Contents

module Spruz
  module StringUnderscore
    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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spruz-0.2.13 lib/spruz/string_underscore.rb
spruz-0.2.12 lib/spruz/string_underscore.rb
spruz-0.2.11 lib/spruz/string_underscore.rb
spruz-0.2.10 lib/spruz/string_underscore.rb