91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/facebooker/parser.rb', line 91
def self.hashinate(response_element)
response_element.children.reject{|c| c.text? }.inject({}) do |hash, child|
hash[child.name] =
if (child['nil'] == 'true')
nil
elsif (child.children.size == 1 && child.children.first.text?) || (child.children.size == 0 && child['list'] != 'true')
anonymous_field_from(child, hash) || child.content.strip
elsif child['list'] == 'true'
child.children.reject{|c| c.text? }.map { |subchild| hash_or_value_for(subchild)}
else
child.children.reject{|c| c.text? }.inject({}) do |subhash, subchild|
subhash[subchild.name] = hash_or_value_for(subchild)
subhash
end
end
hash
end
end
|