Parent

Class/Module Index [+]

Quicksearch

HTML5::TreeBuilders::SimpleTree::Node

Attributes

attributes[RW]

a dict holding name, value pairs for attributes of the node

name[RW]

Node representing an item in the tree. name - The tag name associated with the node

value[RW]

The value of the current node (applies to text nodes and comments

Public Class Methods

new(name) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 19
def initialize name
  super
  @name       = name
  @value      = nil
  @attributes = {}
end

Public Instance Methods

appendChild(node) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 26
def appendChild node
  if node.kind_of? TextNode and 
    childNodes.length > 0 and childNodes.last.kind_of? TextNode
    childNodes.last.value += node.value
  else
    childNodes << node
  end
  node.parent = self
end
cloneNode() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 41
def cloneNode
  newNode = self.class.new name
  attributes.each {|name,value| newNode.attributes[name] = value}
  newNode.value = value
  newNode
end
hasContent() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 73
def hasContent
  childNodes.length > 0
end
insertBefore(node, refNode) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 56
def insertBefore node, refNode
  index = childNodes.index(refNode)
  if node.kind_of?(TextNode) && index > 0 && childNodes[index-1].kind_of?(TextNode)
    childNodes[index-1].value += node.value
  else
    childNodes.insert index, node
  end
end
insertText(data, before=nil) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 48
def insertText data, before=nil
  if before
    insertBefore TextNode.new(data), before
  else
    appendChild TextNode.new(data)
  end
end
printTree(indent=0) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 65
def printTree indent=0
  tree = "\n|%s%s" % [' '* indent, self.to_s]
  for child in childNodes
    tree += child.printTree(indent + 2)
  end
  return tree
end
removeChild(node) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 36
def removeChild node
   childNodes.delete node
   node.parent = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.