Class: Synvert::Rewriter::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/synvert/rewriter/scopes.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Scope

Returns a new instance of Scope.



24
25
26
# File 'lib/synvert/rewriter/scopes.rb', line 24

def initialize(options)
  @options = options
end

Instance Method Details

#matching_nodes(nodes) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/synvert/rewriter/scopes.rb', line 28

def matching_nodes(nodes)
  matching_nodes = []
  while node = nodes.shift
    matching_nodes << node if node.match?(@options)
    node.recursive_children do |child_node|
      matching_nodes << child_node if child_node.match?(@options)
    end
  end
  matching_nodes
end