Class: XmlParsable::Elements::TextElement
- Inherits:
-
XmlElement::Node
- Object
- AbstractElement
- XmlElement::Node
- XmlParsable::Elements::TextElement
- Defined in:
- lib/xmlparsable/elements/text.rb
Overview
Parses content into a ruby String value. Discards comments and flattens children elements so “abc def what<!– foo –>ever” is read as “abc def whatever”
Defined Under Namespace
Classes: String
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Attributes inherited from XmlElement::Node
Instance Method Summary collapse
- #close(element, value) ⇒ Object
- #comment(text) ⇒ Object
- #finalize ⇒ Object
-
#initialize(name, attributes, parent, arguments) ⇒ TextElement
constructor
A new instance of TextElement.
- #open(name, attributes) ⇒ Object
- #read(text) ⇒ Object
Methods inherited from XmlElement::Node
Methods inherited from AbstractElement
Constructor Details
#initialize(name, attributes, parent, arguments) ⇒ TextElement
Returns a new instance of TextElement.
15 16 17 18 |
# File 'lib/xmlparsable/elements/text.rb', line 15 def initialize(name, attributes, parent, arguments) @name, @attributes, @parent, @arguments, @text = name, attributes, parent, arguments, String.new end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
13 14 15 |
# File 'lib/xmlparsable/elements/text.rb', line 13 def attributes @attributes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/xmlparsable/elements/text.rb', line 13 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'lib/xmlparsable/elements/text.rb', line 13 def parent @parent end |
Instance Method Details
#close(element, value) ⇒ Object
31 32 33 |
# File 'lib/xmlparsable/elements/text.rb', line 31 def close(element, value) @text << value end |
#comment(text) ⇒ Object
28 29 |
# File 'lib/xmlparsable/elements/text.rb', line 28 def comment(text) end |
#finalize ⇒ Object
35 36 37 38 |
# File 'lib/xmlparsable/elements/text.rb', line 35 def finalize @text.instance_variable_set(:@xmlattrs, @attributes) @parent.close(self, @text) end |
#open(name, attributes) ⇒ Object
20 21 22 |
# File 'lib/xmlparsable/elements/text.rb', line 20 def open(name, attributes) TextElement.new(name, attributes, self, @arguments) end |
#read(text) ⇒ Object
24 25 26 |
# File 'lib/xmlparsable/elements/text.rb', line 24 def read(text) @text << text end |