Class HTML5::TreeWalkers::NonRecursiveTreeWalker
In: lib/feed_tools/vendor/html5/lib/html5/treewalkers/base.rb
Parent: TreeWalkers::Base

Methods

Public Instance methods

[Source]

     # File lib/feed_tools/vendor/html5/lib/html5/treewalkers/base.rb, line 98
 98:   def each
 99:     current_node = @tree
100:     while current_node != nil
101:       details = node_details(current_node)
102:       has_children = false
103: 
104:       case details.shift
105:       when :DOCTYPE
106:         yield doctype(*details)
107: 
108:       when :TEXT
109:         text(*details) {|token| yield token}
110: 
111:       when :ELEMENT
112:         name, attributes, has_children = details
113:         if VOID_ELEMENTS.include?(name)
114:           yield empty_tag(name, attributes.to_a, has_children)
115:           has_children = false
116:         else
117:           yield start_tag(name, attributes.to_a)
118:         end
119: 
120:       when :COMMENT
121:         yield comment(details[0])
122: 
123:       when :DOCUMENT, :DOCUMENT_FRAGMENT
124:         has_children = true
125: 
126:       when nil
127:         # ignore (REXML::XMLDecl is an example)
128: 
129:       else
130:         yield unknown(details[0])
131:       end
132: 
133:       first_child = has_children ? first_child(current_node) : nil
134:       if first_child != nil
135:         current_node = first_child
136:       else
137:         while current_node != nil
138:           details = node_details(current_node)
139:           if details.shift == :ELEMENT
140:             name, attributes, has_children = details
141:             yield end_tag(name) if !VOID_ELEMENTS.include?(name)
142:           end
143: 
144:           if @tree == current_node
145:             current_node = nil
146:           else
147:             next_sibling = next_sibling(current_node)
148:             if next_sibling != nil
149:               current_node = next_sibling
150:               break
151:             end
152: 
153:             current_node = parent(current_node)
154:           end
155:         end
156:       end
157:     end
158:   end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treewalkers/base.rb, line 86
86:   def first_child(node)
87:     raise NotImplementedError
88:   end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treewalkers/base.rb, line 90
90:   def next_sibling(node)
91:     raise NotImplementedError
92:   end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treewalkers/base.rb, line 82
82:   def node_details(node)
83:     raise NotImplementedError
84:   end

[Source]

    # File lib/feed_tools/vendor/html5/lib/html5/treewalkers/base.rb, line 94
94:   def parent(node)
95:     raise NotImplementedError
96:   end

[Validate]