Class: Synvert::Rewriter::Scopes

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

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Scopes

Returns a new instance of Scopes.



5
6
7
# File 'lib/synvert/rewriter/scopes.rb', line 5

def initialize
  @scopes = []
end

Instance Method Details

#add(options) ⇒ Object



9
10
11
# File 'lib/synvert/rewriter/scopes.rb', line 9

def add(options)
  @scopes << Rewriter::Scope.new(options)
end

#matching_nodes(node) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/synvert/rewriter/scopes.rb', line 13

def matching_nodes(node)
  nodes = [node]
  @scopes.each do |scope|
    break if nodes.empty?
    nodes = scope.matching_nodes(nodes)
  end
  nodes
end