Method: Jinx::Visitor#filter
- Defined in:
- lib/jinx/helpers/visitor.rb
#filter {|parent, children| ... } ⇒ Visitor
Returns a new Visitor which determines which nodes to visit by applying the given block to this visitor. The filter block arguments consist of a parent node and an array of children nodes for the parent. The block can return nil, a single node to visit or a collection of nodes to visit.
186 187 188 189 |
# File 'lib/jinx/helpers/visitor.rb', line 186 def filter raise ArgumentError.new("A filter block is not given to the visitor filter method") unless block_given? self.class.new() { |node| yield(node, node_children(node)) } end |