Sha256: 84fe584a31767abfb4e1c8efff8424746775e375d23b633a75336d0de4441cef

Contents?: true

Size: 447 Bytes

Versions: 53

Compression:

Stored size: 447 Bytes

Contents

class Nori
  module CoreExt
    module String

      # Returns the String in snake_case.
      def snakecase
        str = dup
        str.gsub!(/::/, '/')
        str.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        str.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
        str.tr! ".", "_"
        str.tr! "-", "_"
        str.downcase!
        str
      end unless method_defined?(:snakecase)

    end
  end
end

String.send :include, Nori::CoreExt::String

Version data entries

53 entries across 45 versions & 6 rubygems

Version Path
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb