Sha256: 8a339473de0a6185353854a410ed71a568cf80a9f74dab1e663758a17f14039c

Contents?: true

Size: 369 Bytes

Versions: 4

Compression:

Stored size: 369 Bytes

Contents

# frozen_string_literal: true

module AsyncStorage
  module Util
    module Strings
      module_function

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
async_storage-0.0.4 lib/async_storage/util/strings.rb
async_storage-0.0.3 lib/async_storage/util/strings.rb
async_storage-0.0.2 lib/async_storage/util/strings.rb
async_storage-0.0.1 lib/async_storage/util/strings.rb