Module: MediumApi::Utils Private

Defined in:
lib/medium_api/utils.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.camelcase(string) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
# File 'lib/medium_api/utils.rb', line 24

def camelcase(string)
  first_word, *words = string.split('_')

  [first_word, *words.map(&:capitalize)].join('')
end

.camelcase_keys(hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
# File 'lib/medium_api/utils.rb', line 17

def camelcase_keys(hash)
  hash.transform_keys do |key|
    new_key = camelcase(key.to_s)
    key.is_a?(Symbol) ? new_key.to_sym : new_key
  end
end

.underscore(string) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/medium_api/utils.rb', line 13

def underscore(string)
  string.gsub(/([A-Z])/, '_\1').downcase
end

.underscore_keys(hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
# File 'lib/medium_api/utils.rb', line 6

def underscore_keys(hash)
  hash.transform_keys do |key|
    new_key = underscore(key.to_s)
    key.is_a?(Symbol) ? new_key.to_sym : new_key
  end
end