Class: Synvert::Core::Rewriter::GotoScope
- Defined in:
- lib/synvert/core/rewriter/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
48 49 50 51 52 |
# File 'lib/synvert/core/rewriter/scope.rb', line 48 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.
55 56 57 58 59 60 61 62 |
# File 'lib/synvert/core/rewriter/scope.rb', line 55 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 |