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
nori-2.7.0 lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/lib/nori/core_ext/string.rb