module Hue::TranslateKeys

Public Instance Methods

translate_keys(hash, map) click to toggle source
# File lib/hue/translate_keys.rb, line 3
def translate_keys(hash, map)
  new_hash = {}
  hash.each do |key, value|
    new_key = map[key.to_sym]
    key = new_key if new_key
    new_hash[key] = value
  end
  new_hash
end
unpack_hash(hash, map) click to toggle source
# File lib/hue/translate_keys.rb, line 13
def unpack_hash(hash, map)
  map.each do |local_key, remote_key|
    value = hash[remote_key.to_s]
    next unless value
    instance_variable_set("@#{local_key}", value)
  end
end