Module: AppStoreConnectApi::Utils::StringUtils

Defined in:
lib/app_store_connect_api/utils/string_utils.rb

Class Method Summary collapse

Class Method Details

.camelize(snake_cased_word) ⇒ Object



7
8
9
10
11
12
# File 'lib/app_store_connect_api/utils/string_utils.rb', line 7

def camelize(snake_cased_word)
  snake_cased_word.split('_')
                  .map(&:capitalize)
                  .join
                  .tap { |w| w[0] = w[0].downcase }
end

.pluralize(word) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/app_store_connect_api/utils/string_utils.rb', line 19

def pluralize(word)
  if word.end_with? 's'
    word + 'es'
  elsif word.end_with? 'y'
    word[...-1] + 'ies'
  else
    word + 's'
  end
end

.underscore(camel_cased_word) ⇒ Object



14
15
16
17
# File 'lib/app_store_connect_api/utils/string_utils.rb', line 14

def underscore(camel_cased_word)
  camel_cased_word.gsub(/([a-z])([A-Z])/, '\1_\2')
                  .downcase
end