Class: Synvert::Core::Rewriter::GotoScope
- Defined in:
- lib/synvert/core/rewriter/scope/goto_scope.rb
Overview
Go to and change its scope to a child node.
Instance Method Summary collapse
-
#initialize(instance, child_node_name, &block) ⇒ GotoScope
constructor
Initialize a scope.
-
#process ⇒ Object
Go to a child now, then run the block code with the the child node.
Constructor Details
#initialize(instance, child_node_name, &block) ⇒ GotoScope
Initialize a scope
11 12 13 14 15 |
# File 'lib/synvert/core/rewriter/scope/goto_scope.rb', line 11 def initialize(instance, child_node_name, &block) @instance = instance @child_node_name = child_node_name @block = block end |
Instance Method Details
#process ⇒ Object
Go to a child now, then run the block code with the the child node.
18 19 20 21 22 23 24 25 |
# File 'lib/synvert/core/rewriter/scope/goto_scope.rb', line 18 def process current_node = @instance.current_node return unless current_node child_node = current_node.send @child_node_name @instance.process_with_other_node child_node do @instance.instance_eval &@block end end |