Sha256: bec2dc0815d2cbafd0c7607d5818dbc1c7933102eb3201a99d644d0338769690

Contents?: true

Size: 377 Bytes

Versions: 7

Compression:

Stored size: 377 Bytes

Contents

# frozen_string_literal: true

module RakutenWebService
  module StringSupport
    refine String do
      def to_snake
        gsub(/([a-z]+)([A-Z]{1})/, '\1_\2').downcase
      end

      def to_camel
        gsub(/([a-z]{1})_([a-z]{1})/) do |matched|
          matched = matched.split('_')
          matched[0] + matched[1].capitalize
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rakuten_web_service-1.13.2 lib/rakuten_web_service/string_support.rb
rakuten_web_service-1.13.1 lib/rakuten_web_service/string_support.rb
rakuten_web_service-1.13.0 lib/rakuten_web_service/string_support.rb
rakuten_web_service-1.12.0 lib/rakuten_web_service/string_support.rb
rakuten_web_service-1.11.0 lib/rakuten_web_service/string_support.rb
rakuten_web_service-1.10.0 lib/rakuten_web_service/string_support.rb
rakuten_web_service-1.9.2 lib/rakuten_web_service/string_support.rb