Class: HTML5::TreeBuilders::SimpleTree::Element

Inherits:
Node show all
Defined in:
lib/html5/treebuilders/simpletree.rb

Direct Known Subclasses

DocumentFragment

Instance Attribute Summary collapse

Attributes inherited from Node

#attributes, #name, #value

Attributes inherited from Base::Node

#childNodes, #flags, #parent

Instance Method Summary collapse

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

#namespaceObject

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_sObject



85
86
87
# File 'lib/html5/treebuilders/simpletree.rb', line 85

def to_s
   "<#{namespace ? namespace.to_s + ' ' : ''}#{name}>"
end