Class: Gammo::XPath::AST::Axis::Following

Inherits:
Gammo::XPath::AST::Axis
  • Object
show all
Defined in:
lib/gammo/xpath/ast/axis.rb

Constant Summary

Constants included from Subclassify

Subclassify::NotFoundError

Instance Method Summary collapse

Instance Method Details

#each_following(context_node) ⇒ Object



144
145
146
147
148
149
150
151
152
# File 'lib/gammo/xpath/ast/axis.rb', line 144

def each_following(context_node)
  stack = [context_node]
  until stack.empty?
    node = stack.pop
    yield node unless node == context_node
    stack << node.next_sibling if node.next_sibling
    stack << node.first_child if node.first_child
  end
end

#strain(context, context_node, node_set) ⇒ Object



134
135
136
137
138
139
140
141
142
# File 'lib/gammo/xpath/ast/axis.rb', line 134

def strain(context, context_node, node_set)
  context_node = context_node.owner_element if context_node.instance_of?(Gammo::Attribute)
  while node = context_node.next_sibling
    each_following(node) do |node|
      node_set << node if node_test.match?(node)
    end
    break if context_node.parent.tag != Gammo::Tags::Html
  end
end