Class: HTML5::TreeBuilders::REXML::Element

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

Direct Known Subclasses

DocumentFragment

Instance Attribute Summary

Attributes inherited from Node

#rxobj

Attributes inherited from Base::Node

#_flags, #childNodes, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#appendChild, #hasContent, #insertBefore, #insertText, #removeChild

Methods inherited from Base::Node

#appendChild, #hasContent, #insertBefore, #insertText, #removeChild, #reparentChildren

Constructor Details

#initialize(name) ⇒ Element

Returns a new instance of Element.



65
66
67
# File 'lib/html5/treebuilders/rexml.rb', line 65

def initialize name
  super name
end

Class Method Details

.rxclassObject



61
62
63
# File 'lib/html5/treebuilders/rexml.rb', line 61

def self.rxclass
  ::REXML::Element
end

Instance Method Details

#attributes=(value) ⇒ Object



75
76
77
# File 'lib/html5/treebuilders/rexml.rb', line 75

def attributes= value
  value.each {|name, value| rxobj.attributes[name] = value}
end

#cloneNodeObject



69
70
71
72
73
# File 'lib/html5/treebuilders/rexml.rb', line 69

def cloneNode
  newNode = self.class.new name
  attributes.each {|name,value| newNode.attributes[name] = value}
  newNode
end

#printTree(indent = 0) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/html5/treebuilders/rexml.rb', line 79

def printTree indent=0
  tree = "\n|#{' ' * indent}<#{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