Class: AdobeShare::Node
- Inherits:
-
Object
- Object
- AdobeShare::Node
- Defined in:
- lib/adobeshare/node.rb
Overview
Node Object Utility
Instance Method Summary collapse
-
#initialize(node_xml) ⇒ Node
constructor
A new instance of Node.
-
#to_hash ⇒ Object
Node elements (XML to Hash).
Constructor Details
#initialize(node_xml) ⇒ Node
Returns a new instance of Node.
26 27 28 |
# File 'lib/adobeshare/node.rb', line 26 def initialize(node_xml) @xml = node_xml end |
Instance Method Details
#to_hash ⇒ Object
Node elements (XML to Hash)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/adobeshare/node.rb', line 31 def to_hash # FIXME # XXX # I Think it's not cool. # Maybe there is some good way to exchange from xml to hash...? doc = Document.new(@xml) node = Hash.new doc.elements["/response/node"].attributes.each{|k, v| node[k.to_sym] = v } if doc.elements["/response/children"] node[:children] = Array.new doc.elements["/response/children"].each{|e| child = Hash.new e.attributes.each{|k, v| child[k.to_sym] = v } node[:children] << child } end return node end |