Class: Synvert::Rewriter::Scope
- Inherits:
-
Object
- Object
- Synvert::Rewriter::Scope
- Defined in:
- lib/synvert/rewriter/scope.rb
Instance Method Summary collapse
-
#initialize(instance, options, &block) ⇒ Scope
constructor
A new instance of Scope.
- #process ⇒ Object
Constructor Details
#initialize(instance, options, &block) ⇒ Scope
Returns a new instance of Scope.
5 6 7 8 9 |
# File 'lib/synvert/rewriter/scope.rb', line 5 def initialize(instance, , &block) @instance = instance @options = @block = block end |
Instance Method Details
#process ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/synvert/rewriter/scope.rb', line 11 def process current_node = @instance.current_node return unless current_node process_with_node current_node do matching_nodes = [] matching_nodes << current_node if current_node.match? @instance, @options current_node.recursive_children do |child_node| matching_nodes << child_node if child_node.match? @instance, @options end matching_nodes.each do |matching_node| process_with_node matching_node do @instance.instance_eval &@block end end end end |