Sha256: b8f1ff2b867bbd37229b9894aed9e805071e0368b161974e74fc6f1bd9148769

Contents?: true

Size: 315 Bytes

Versions: 35

Compression:

Stored size: 315 Bytes

Contents

# frozen_string_literal: true

module Groundskeeper
  # Helpers for strings.
  module StringUtils
    def self.underscore(word)
      return "" unless word.respond_to?(:gsub)

      word
        .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
        .gsub(/([a-z\d])([A-Z])/, '\1_\2')
        .downcase
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
groundskeeper-bitcore-0.34.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.33.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.32.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.31.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.29.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.28.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.27.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.26.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.24.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.23.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.22.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.21.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.20.1 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.19.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.18.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.17.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.16.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.15.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.14.0 lib/groundskeeper/string_utils.rb
groundskeeper-bitcore-0.13.0 lib/groundskeeper/string_utils.rb