Module: HabiticaClient::Restful::ClassMethods

Included in:
HabiticaClient::Restful
Defined in:
lib/habitica_client/restful.rb

Instance Method Summary collapse

Instance Method Details

#parse(client, attributes) ⇒ Object



11
12
13
# File 'lib/habitica_client/restful.rb', line 11

def parse(client, attributes)
  new(client, remap(attributes))
end

#remap(attributes) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/habitica_client/restful.rb', line 15

def remap(attributes)
  remapped = attributes.map do |k, v|
    [k.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase, v]
  end

  remapped.delete_if do |k, _v|
    k.match(/^_/)
  end

  Hash[remapped]
end