Class: REXML::Element
- Inherits:
-
Object
- Object
- REXML::Element
- Defined in:
- lib/niftycloud/request.rb
Instance Method Summary collapse
Instance Method Details
#to_h ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/niftycloud/request.rb', line 112 def to_h hash = {} if self.has_elements? self.elements.each do |e| if e.has_elements? if hash[e.name].nil? hash[e.name] = e.to_h elsif hash[e.name].is_a?(Array) hash[e.name].push( e.to_h ) else hash[e.name] = [ hash[e.name] ] hash[e.name].push( e.to_h ) end elsif e.has_text? hash[e.name] = e.text end end else hash[self.name] = self.text end hash end |