Class: Calligraphy::XML::Node
- Inherits:
-
Object
- Object
- Calligraphy::XML::Node
- Defined in:
- lib/calligraphy/xml/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(node = nil) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(node = nil) ⇒ Node
Returns a new instance of Node.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/calligraphy/xml/node.rb', line 5 def initialize(node=nil) unless node.nil? @name = node.name @text = node.text unless node.text.empty? if node.namespace @namespace = Calligraphy::XML::Namespace.new node.namespace end if node.children&.length > 0 @children = [] node.children.each do |child| @children.push Calligraphy::XML::Node.new child end end end end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/calligraphy/xml/node.rb', line 3 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/calligraphy/xml/node.rb', line 3 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
3 4 5 |
# File 'lib/calligraphy/xml/node.rb', line 3 def namespace @namespace end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/calligraphy/xml/node.rb', line 3 def text @text end |