Class: HTML5::TreeWalkers::Hpricot::TreeWalker
Instance Method Summary
collapse
#each
Methods inherited from Base
#each, #initialize, #to_ary
#_, #comment, #doctype, #empty_tag, #end_tag, #error, #normalize_attrs, #start_tag, #text, #unknown
Instance Method Details
#first_child(node) ⇒ Object
34
35
36
|
# File 'lib/feed_tools/vendor/html5/lib/html5/treewalkers/hpricot.rb', line 34
def first_child(node)
node.children.first
end
|
#next_sibling(node) ⇒ Object
38
39
40
|
# File 'lib/feed_tools/vendor/html5/lib/html5/treewalkers/hpricot.rb', line 38
def next_sibling(node)
node.next_node
end
|
#node_details(node) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/feed_tools/vendor/html5/lib/html5/treewalkers/hpricot.rb', line 9
def node_details(node)
case node
when ::Hpricot::Elem
if node.name.empty?
[:DOCUMENT_FRAGMENT]
else
[:ELEMENT, node.name,
node.attributes.map {|name, value| [name, value]},
!node.empty?]
end
when ::Hpricot::Text
[:TEXT, node.content]
when ::Hpricot::Comment
[:COMMENT, node.content]
when ::Hpricot::Doc
[:DOCUMENT]
when ::Hpricot::DocType
[:DOCTYPE, node.target, node.public_id, node.system_id]
when ::Hpricot::XMLDecl
[nil]
else
[:UNKNOWN, node.class.inspect]
end
end
|
#parent(node) ⇒ Object
42
43
44
|
# File 'lib/feed_tools/vendor/html5/lib/html5/treewalkers/hpricot.rb', line 42
def parent(node)
node.parent
end
|