Class: HTML5::TreeWalkers::REXML::TreeWalker

Inherits:
NonRecursiveTreeWalker show all
Defined in:
lib/feed_tools/vendor/html5/lib/html5/treewalkers/rexml.rb

Instance Method Summary collapse

Methods inherited from NonRecursiveTreeWalker

#each

Methods inherited from Base

#each, #initialize, #to_ary

Methods included from TokenConstructor

#_, #comment, #doctype, #empty_tag, #end_tag, #error, #normalize_attrs, #start_tag, #text, #unknown

Constructor Details

This class inherits a constructor from HTML5::TreeWalkers::Base

Instance Method Details

#first_child(node) ⇒ Object



34
35
36
# File 'lib/feed_tools/vendor/html5/lib/html5/treewalkers/rexml.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/rexml.rb', line 38

def next_sibling(node)
  node.next_sibling
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/rexml.rb', line 9

def node_details(node)
  case node
  when ::REXML::Document
    [:DOCUMENT]
  when ::REXML::Element
    if !node.name
      [:DOCUMENT_FRAGMENT]
    else
      [:ELEMENT, node.name,
        node.attributes.map {|name,value| [name,value]},
        node.has_elements? || node.has_text?]
    end
  when ::REXML::Text
    [:TEXT, node.value]
  when ::REXML::Comment
    [:COMMENT, node.string]
  when ::REXML::DocType
    [:DOCTYPE, node.name, node.public, node.system]
  when ::REXML::XMLDecl
    [nil]
  else
    [:UNKNOWN, node.class.inspect]
  end
end

#parent(node) ⇒ Object



42
43
44
# File 'lib/feed_tools/vendor/html5/lib/html5/treewalkers/rexml.rb', line 42

def parent(node)
  node.parent
end