Sha256: 200f4bef0ddc43fa6029b38b5e144732e2643c7358ba3a6908c61083c3e9cda3

Contents?: true

Size: 521 Bytes

Versions: 2

Compression:

Stored size: 521 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

2 entries across 2 versions & 1 rubygems

Version Path
bing_ads_ruby_sdk-1.5.2 lib/bing_ads_ruby_sdk/string_utils.rb
bing_ads_ruby_sdk-1.5.0 lib/bing_ads_ruby_sdk/string_utils.rb