Class: HTML5::TreeBuilders::REXML::TextNode
- Inherits:
-
Node
- Object
- Base::Node
- Node
- HTML5::TreeBuilders::REXML::TextNode
- Defined in:
- lib/html5/treebuilders/rexml.rb
Instance Attribute Summary
Attributes inherited from Node
Attributes inherited from Base::Node
Instance Method Summary collapse
-
#initialize(data) ⇒ TextNode
constructor
A new instance of TextNode.
- #printTree(indent = 0) ⇒ Object
Methods inherited from Node
#appendChild, #hasContent, #insertBefore, #insertText, #removeChild
Methods inherited from Base::Node
#appendChild, #cloneNode, #hasContent, #insertBefore, #insertText, #removeChild, #reparentChildren
Constructor Details
#initialize(data) ⇒ TextNode
Returns a new instance of TextNode.
161 162 163 164 165 166 167 168 |
# File 'lib/html5/treebuilders/rexml.rb', line 161 def initialize data raw = data.gsub('&', '&').gsub('<', '<').gsub('>', '>') if String.method_defined? :encode @rxobj = ::REXML::Text.new(raw.force_encoding('UTF-8'), true, nil, true) else @rxobj = ::REXML::Text.new(raw, true, nil, true) end end |
Instance Method Details
#printTree(indent = 0) ⇒ Object
170 171 172 |
# File 'lib/html5/treebuilders/rexml.rb', line 170 def printTree indent=0 "\n|#{' ' * indent}\"#{rxobj.value}\"" end |