Sha256: f6b4002e53e32c9d131ece52b3aed194b384ff7212d2bbb1d1239adb069b1490

Contents?: true

Size: 537 Bytes

Versions: 8

Compression:

Stored size: 537 Bytes

Contents

# frozen_string_literal: true

module BingAdsRubySdk
  module StringUtils

    def self.camelize(string)
      string.split(UNDERSCORE).collect!{ |w| w.capitalize }.join
    end

    def self.snakize(string)
      string.gsub(MULTIPLE_CAPSREGEX, MATCHING_PATTERN)
            .gsub(SPLIT_REGEX, MATCHING_PATTERN)
            .tr('-', '_')
            .downcase
            .to_sym
    end

    UNDERSCORE = '_'
    MULTIPLE_CAPSREGEX = /([A-Z]+)([A-Z][a-z])/
    SPLIT_REGEX = /([a-z\d])([A-Z])/
    MATCHING_PATTERN = '\1_\2'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bing_ads_ruby_sdk-1.3.4 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.3.3 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.3.2 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.3.1 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.3.0 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.2.0 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.1.1 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.0.0 lib/bing_ads_ruby_sdk/string_utils.rb