| Class | HTML5::TreeBuilders::Hpricot::Node |
| In: |
lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb
|
| Parent: | Base::Node |
| hpricot | [RW] |
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 17
17: def initialize(name)
18: super(name)
19: @hpricot = self.class.hpricot_class.new name
20: end
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 22
22: def appendChild(node)
23: if node.kind_of?(TextNode) and childNodes.any? and childNodes.last.kind_of?(TextNode)
24: childNodes.last.hpricot.content = childNodes.last.hpricot.content + node.hpricot.content
25: else
26: childNodes << node
27: hpricot.children << node.hpricot
28: end
29: if (oldparent = node.hpricot.parent) != nil
30: oldparent.children.delete_at(oldparent.children.index(node.hpricot))
31: end
32: node.hpricot.parent = hpricot
33: node.parent = self
34: end
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 61
61: def hasContent
62: childNodes.any?
63: end
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 51
51: def insertBefore(node, refNode)
52: index = childNodes.index(refNode)
53: if node.kind_of?(TextNode) and index > 0 and childNodes[index-1].kind_of?(TextNode)
54: childNodes[index-1].hpricot.content = childNodes[index-1].hpricot.to_s + node.hpricot.to_s
55: else
56: refNode.hpricot.parent.insert_before(node.hpricot,refNode.hpricot)
57: childNodes.insert(index, node)
58: end
59: end
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 43
43: def insertText(data, before=nil)
44: if before
45: insertBefore(TextNode.new(data), before)
46: else
47: appendChild(TextNode.new(data))
48: end
49: end