Class: XmlParsable::Elements::XmlElement::Node
- Inherits:
-
AbstractElement
- Object
- AbstractElement
- XmlParsable::Elements::XmlElement::Node
- Defined in:
- lib/xmlparsable/elements/xml.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#xmlattr ⇒ Object
readonly
Returns the value of attribute xmlattr.
Instance Method Summary collapse
- #close(element, value) ⇒ Object
- #comment(text) ⇒ Object
- #finalize ⇒ Object
-
#initialize(name, attributes, parent, arguments) ⇒ Node
constructor
A new instance of Node.
- #open(name, attributes) ⇒ Object
- #read(text) ⇒ Object
- #to_s(buffer = "") ⇒ Object
Methods inherited from AbstractElement
Constructor Details
#initialize(name, attributes, parent, arguments) ⇒ Node
Returns a new instance of Node.
16 17 18 19 |
# File 'lib/xmlparsable/elements/xml.rb', line 16 def initialize(name, attributes, parent, arguments) @name, @attributes, @parent, @arguments, @children = name, attributes, parent, arguments, Array.new end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
14 15 16 |
# File 'lib/xmlparsable/elements/xml.rb', line 14 def attributes @attributes end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
14 15 16 |
# File 'lib/xmlparsable/elements/xml.rb', line 14 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/xmlparsable/elements/xml.rb', line 14 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
14 15 16 |
# File 'lib/xmlparsable/elements/xml.rb', line 14 def parent @parent end |
#xmlattr ⇒ Object (readonly)
Returns the value of attribute xmlattr.
14 15 16 |
# File 'lib/xmlparsable/elements/xml.rb', line 14 def xmlattr @xmlattr end |
Instance Method Details
#close(element, value) ⇒ Object
33 34 35 |
# File 'lib/xmlparsable/elements/xml.rb', line 33 def close(element, value) @children << value end |
#comment(text) ⇒ Object
29 30 31 |
# File 'lib/xmlparsable/elements/xml.rb', line 29 def comment(text) @children << Comment.new(text, self) end |
#finalize ⇒ Object
37 38 39 |
# File 'lib/xmlparsable/elements/xml.rb', line 37 def finalize @parent.close(self, self) end |
#open(name, attributes) ⇒ Object
21 22 23 |
# File 'lib/xmlparsable/elements/xml.rb', line 21 def open(name, attributes) Node.new(name, attributes, self, @arguments) end |
#read(text) ⇒ Object
25 26 27 |
# File 'lib/xmlparsable/elements/xml.rb', line 25 def read(text) @children << Text.new(text, self) end |
#to_s(buffer = "") ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/xmlparsable/elements/xml.rb', line 41 def to_s(buffer = "") buffer << "<#{@name}" @attributes.each{|name, value| buffer << %[ #{name}='#{value}'] } if @children.empty? buffer << "/>" else buffer << ">" @children.each{|child| child.to_s(buffer) } buffer << "</#{@name}>" end end |