module Angus::Remote::Response::Hash
Public Instance Methods
elements()
click to toggle source
# File lib/angus/remote/response/hash.rb, line 7 def elements @elements ||= {} end
to_hash()
click to toggle source
Creates a hash base on the object
The object must have an instance variable @elements that is a hash
that keys => element name, value => element value
# File lib/angus/remote/response/hash.rb, line 15 def to_hash hash = {} elements.each do |name, value| if value.is_a?(Angus::Remote::Response::Hash) hash[name] = value.to_hash elsif value.is_a?(Array) hash[name] = build_hash_from_array(value) else hash[name] = value end end hash end
Private Instance Methods
build_hash_from_array(elements)
click to toggle source
# File lib/angus/remote/response/hash.rb, line 33 def build_hash_from_array(elements) elements.map do |element| if element.is_a?(Angus::Remote::Response::Hash) element.to_hash elsif element.is_a?(Array) build_hash_from_array(element) else element end end end