Class: HTML5::TreeBuilders::SimpleTree::Element
- Inherits:
-
Node
- Object
- Base::Node
- Node
- HTML5::TreeBuilders::SimpleTree::Element
- Defined in:
- lib/html5/treebuilders/simpletree.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#namespace ⇒ Object
Returns the value of attribute namespace.
Attributes inherited from Node
Attributes inherited from Base::Node
Instance Method Summary collapse
-
#initialize(name, namespace = nil) ⇒ Element
constructor
A new instance of Element.
- #printTree(indent = 0) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Node
#appendChild, #cloneNode, #hasContent, #insertBefore, #insertText, #removeChild
Methods inherited from Base::Node
#appendChild, #cloneNode, #hasContent, #insertBefore, #insertText, #removeChild, #reparentChildren
Constructor Details
#initialize(name, namespace = nil) ⇒ Element
Returns a new instance of Element.
80 81 82 83 |
# File 'lib/html5/treebuilders/simpletree.rb', line 80 def initialize(name, namespace=nil) super(name) @namespace = namespace end |
Instance Attribute Details
#namespace ⇒ Object
Returns the value of attribute namespace.
79 80 81 |
# File 'lib/html5/treebuilders/simpletree.rb', line 79 def namespace @namespace end |
Instance Method Details
#printTree(indent = 0) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/html5/treebuilders/simpletree.rb', line 89 def printTree indent=0 tree = "\n|%s%s" % [' '* indent, self.to_s] indent += 2 for name, value in attributes tree += "\n|%s%s=\"%s\"" % [' ' * indent, name, value] end for child in childNodes tree += child.printTree(indent) end tree end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/html5/treebuilders/simpletree.rb', line 85 def to_s "<#{namespace ? namespace.to_s + ' ' : ''}#{name}>" end |