Class HTML5::TreeBuilders::SimpleTree::Node
In: lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb
Parent: Base::Node

Methods

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

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 19
19:         def initialize name
20:           super
21:           @name       = name
22:           @value      = nil
23:           @attributes = {}
24:         end

Public Instance methods

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 26
26:         def appendChild node
27:           if node.kind_of? TextNode and 
28:             childNodes.length > 0 and childNodes.last.kind_of? TextNode
29:             childNodes.last.value += node.value
30:           else
31:             childNodes << node
32:           end
33:           node.parent = self
34:         end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 41
41:         def cloneNode
42:           newNode = self.class.new name
43:           attributes.each {|name,value| newNode.attributes[name] = value}
44:           newNode.value = value
45:           newNode
46:         end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 73
73:         def hasContent
74:           childNodes.length > 0
75:         end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 56
56:         def insertBefore node, refNode
57:           index = childNodes.index(refNode)
58:           if node.kind_of?(TextNode) && index > 0 && childNodes[index-1].kind_of?(TextNode)
59:             childNodes[index-1].value += node.value
60:           else
61:             childNodes.insert index, node
62:           end
63:         end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 48
48:         def insertText data, before=nil
49:           if before
50:             insertBefore TextNode.new(data), before
51:           else
52:             appendChild TextNode.new(data)
53:           end
54:         end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 65
65:         def printTree indent=0
66:           tree = "\n|%s%s" % [' '* indent, self.to_s]
67:           for child in childNodes
68:             tree += child.printTree(indent + 2)
69:           end
70:           return tree
71:         end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treebuilders/simpletree.rb, line 36
36:         def removeChild node
37:            childNodes.delete node
38:            node.parent = nil
39:         end

[Validate]