Class: Oga::XML::Text
- Inherits:
-
CharacterNode
- Object
- Node
- CharacterNode
- Oga::XML::Text
- Defined in:
- lib/oga/xml/text.rb
Overview
Class containing information about a single text node. Text nodes don't have any children, attributes and the likes; just text.
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(*args) ⇒ Text
constructor
A new instance of Text.
-
#text ⇒ String
Returns the text as a String.
- #text=(value) ⇒ Object
- #to_xml ⇒ Object
Methods inherited from CharacterNode
Methods inherited from Node
#after, #before, #children, #children=, #html?, #next, #next_element, #parent, #previous, #previous_element, #remove, #replace, #root_node, #xml?
Methods included from Traversal
Constructor Details
#initialize(*args) ⇒ Text
Returns a new instance of Text.
8 9 10 11 12 |
# File 'lib/oga/xml/text.rb', line 8 def initialize(*args) super @decoded = false end |
Instance Method Details
#text ⇒ String
Returns the text as a String. Upon the first call any XML/HTML entities are decoded.
28 29 30 31 32 33 34 35 |
# File 'lib/oga/xml/text.rb', line 28 def text if decode_entities? @text = EntityDecoder.try_decode(@text, html?) @decoded = true end @text end |
#text=(value) ⇒ Object
17 18 19 20 |
# File 'lib/oga/xml/text.rb', line 17 def text=(value) @decoded = false @text = value end |