Sha256: 16dc8b111db8efaf6ac0bc272074f0d1244fc286f7c63828e83203f9504bd9d3

Contents?: true

Size: 451 Bytes

Versions: 8

Compression:

Stored size: 451 Bytes

Contents

module Wasabi
  module CoreExt
    module String

      # Returns the String in snakecase.
      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, Wasabi::CoreExt::String

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
wasabi-3.5.0 lib/wasabi/core_ext/string.rb
wasabi-3.4.0 lib/wasabi/core_ext/string.rb
wasabi-3.3.1 lib/wasabi/core_ext/string.rb
wasabi-3.3.0 lib/wasabi/core_ext/string.rb
wasabi_with_adapter-3.2.4 lib/wasabi/core_ext/string.rb
wasabi-3.2.3 lib/wasabi/core_ext/string.rb
wasabi-3.2.2 lib/wasabi/core_ext/string.rb
wasabi-3.2.1 lib/wasabi/core_ext/string.rb