Sha256: 5a91ccef89c22d5ca348beaef8bc98b3d84abbdb192486d7133ac13d7e5ca668

Contents?: true

Size: 1.16 KB

Versions: 32

Compression:

Stored size: 1.16 KB

Contents

# Encoding: utf-8
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Utility that generates up resource names for entities given IDs.

module Google
  module Ads
    module GoogleAds
      module Utils
        # Takes a string and converts it from snake case to camel case. e.g:
        # foo_service becomes FooService
        def self.camelize(string)
          string.to_str.split("_").map(&:capitalize).join
        end

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

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
google-ads-googleads-31.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-30.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-29.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-28.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-27.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-26.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-25.0.2 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-25.0.1 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-25.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-24.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-23.1.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-23.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-22.1.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-22.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-21.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-20.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-19.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-18.1.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-18.0.0 lib/google/ads/google_ads/utils/string_utils.rb
google-ads-googleads-17.0.0 lib/google/ads/google_ads/utils/string_utils.rb