Sha256: 7ecc62ed145866e29897332bf26b1e6ec5c03c029776ada75dbb58ee0478de16

Contents?: true

Size: 351 Bytes

Versions: 9

Compression:

Stored size: 351 Bytes

Contents

module MessagesDictionary
  class SpecialString
    attr_accessor :string

    def initialize(string)
      @string = string
    end

    def snake_case
      string.gsub(/::/, '/').
          gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
          gsub(/([a-z\d])([A-Z])/,'\1_\2').
          tr("-", "_").
          downcase
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
messages_dictionary-1.0.0 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.1.3.2 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.1.3.1 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.1.3 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.1.2 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.1.1 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.0.2 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.0.1 lib/messages_dictionary/utils/snake_case.rb
messages_dictionary-0.0.1.rc2 lib/messages_dictionary/utils/snake_case.rb