Sha256: afe21f2b21c179a963c7310eebd2a79bc794c764f79f1ed452af59bb8ac38ade

Contents?: true

Size: 375 Bytes

Versions: 10

Compression:

Stored size: 375 Bytes

Contents

# frozen_string_literal: true

module Wasabi
  module CoreExt
    module String

      def self.snakecase(str)
        str = 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

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
wasabi-5.1.0 lib/wasabi/core_ext/string.rb
wasabi-5.0.3 lib/wasabi/core_ext/string.rb
wasabi-5.0.2 lib/wasabi/core_ext/string.rb
wasabi-5.0.1 lib/wasabi/core_ext/string.rb
wasabi-5.0.0 lib/wasabi/core_ext/string.rb
wasabi-4.0.0 lib/wasabi/core_ext/string.rb
wasabi-3.8.0 lib/wasabi/core_ext/string.rb
wasabi-3.7.0 lib/wasabi/core_ext/string.rb
wasabi-3.6.1 lib/wasabi/core_ext/string.rb
wasabi-3.6.0 lib/wasabi/core_ext/string.rb