Class: Ruote::XmlReader::Node
- Inherits:
-
Object
- Object
- Ruote::XmlReader::Node
- Defined in:
- lib/ruote/reader/xml.rb
Overview
A helper class to store the temporary tree while it gets read.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(parent, name, attributes) ⇒ Node
constructor
A new instance of Node.
- #to_a ⇒ Object
Constructor Details
#initialize(parent, name, attributes) ⇒ Node
Returns a new instance of Node.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ruote/reader/xml.rb', line 50 def initialize(parent, name, attributes) @parent = parent @name = name @attributes = attributes.inject({}) { |h, (k, v)| h[k.gsub(/-/, '_')] = v h } @children = [] parent.children << self if parent end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
48 49 50 |
# File 'lib/ruote/reader/xml.rb', line 48 def attributes @attributes end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
48 49 50 |
# File 'lib/ruote/reader/xml.rb', line 48 def children @children end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
48 49 50 |
# File 'lib/ruote/reader/xml.rb', line 48 def parent @parent end |
Instance Method Details
#to_a ⇒ Object
63 64 65 66 |
# File 'lib/ruote/reader/xml.rb', line 63 def to_a [ @name, @attributes, @children.collect { |c| c.to_a } ] end |