Parent

Class/Module Index [+]

Quicksearch

HTML5::TreeBuilders::Hpricot::Node

Attributes

hpricot[RW]

Public Class Methods

new(name) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 16
def initialize(name)
  super(name)
  @hpricot = self.class.hpricot_class.new name
end

Public Instance Methods

appendChild(node) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 21
def appendChild(node)
  if node.kind_of?(TextNode) and childNodes.any? and childNodes.last.kind_of?(TextNode)
    childNodes.last.hpricot.content = childNodes.last.hpricot.content + node.hpricot.content
  else
    childNodes << node
    hpricot.children << node.hpricot
  end
  if (oldparent = node.hpricot.parent) != nil
    oldparent.children.delete_at(oldparent.children.index(node.hpricot))
  end
  node.hpricot.parent = hpricot
  node.parent = self
end
hasContent() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 60
def hasContent
  childNodes.any?
end
insertBefore(node, refNode) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 50
def insertBefore(node, refNode)
  index = childNodes.index(refNode)
  if node.kind_of?(TextNode) and index > 0 and childNodes[index-1].kind_of?(TextNode)
    childNodes[index-1].hpricot.content = childNodes[index-1].hpricot.to_s + node.hpricot.to_s
  else
    refNode.hpricot.parent.insert_before(node.hpricot,refNode.hpricot)
    childNodes.insert(index, node)
  end
end
insertText(data, before=nil) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 42
def insertText(data, before=nil)
  if before
    insertBefore(TextNode.new(data), before)
  else
    appendChild(TextNode.new(data))
  end
end
removeChild(node) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb, line 35
def removeChild(node)
   childNodes.delete(node)
   hpricot.children.delete_at(hpricot.children.index(node.hpricot))
   node.hpricot.parent = nil
   node.parent = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.