Class: HTML5::TreeBuilders::REXML::Element
- Inherits:
-
Node
- Object
- Base::Node
- Node
- HTML5::TreeBuilders::REXML::Element
- Defined in:
- lib/html5/treebuilders/rexml.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Attributes inherited from Node
Attributes inherited from Base::Node
Class Method Summary collapse
Instance Method Summary collapse
- #attributes=(value) ⇒ Object
- #cloneNode ⇒ Object
-
#initialize(name, namespace = nil) ⇒ Element
constructor
A new instance of Element.
- #printTree(indent = 0) ⇒ Object
Methods inherited from Node
#appendChild, #hasContent, #insertBefore, #insertText, #removeChild
Methods inherited from Base::Node
#appendChild, #hasContent, #insertBefore, #insertText, #removeChild, #reparentChildren
Constructor Details
#initialize(name, namespace = nil) ⇒ Element
Returns a new instance of Element.
66 67 68 69 |
# File 'lib/html5/treebuilders/rexml.rb', line 66 def initialize name, namespace=nil super name @namespace = namespace end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
61 62 63 |
# File 'lib/html5/treebuilders/rexml.rb', line 61 def namespace @namespace end |
Class Method Details
.rxclass ⇒ Object
62 63 64 |
# File 'lib/html5/treebuilders/rexml.rb', line 62 def self.rxclass ::REXML::Element end |
Instance Method Details
#attributes=(value) ⇒ Object
77 78 79 |
# File 'lib/html5/treebuilders/rexml.rb', line 77 def attributes= value value.each {|name, v| rxobj.attributes[name] = v} end |
#cloneNode ⇒ Object
71 72 73 74 75 |
# File 'lib/html5/treebuilders/rexml.rb', line 71 def cloneNode newNode = self.class.new name attributes.each {|name,value| newNode.attributes[name] = value} newNode end |
#printTree(indent = 0) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/html5/treebuilders/rexml.rb', line 81 def printTree indent=0 tree = "\n|#{' ' * indent}<#{namespace ? namespace.to_s + ' ' : ''}#{name}>" indent += 2 for name, value in attributes next if name == 'xmlns' tree += "\n|#{' ' * indent}#{name}=\"#{value}\"" end for child in childNodes tree += child.printTree(indent) end tree end |