Class: Synvert::Core::Rewriter::ReplaceAction
- Defined in:
- lib/synvert/core/rewriter/action/replace_action.rb
Overview
ReplaceAction to replace child node with code.
Constant Summary
Constants inherited from Action
Action::DEFAULT_INDENT, Action::DEFAULT_OPTIONS
Instance Method Summary collapse
-
#begin_pos ⇒ Integer
Begin position of code to replace.
-
#end_pos ⇒ Integer
End position of code to replace.
-
#initialize(instance, selector, with:) ⇒ ReplaceAction
constructor
A new instance of ReplaceAction.
-
#rewritten_code ⇒ String
The rewritten source code.
Methods inherited from Action
Constructor Details
#initialize(instance, selector, with:) ⇒ ReplaceAction
Returns a new instance of ReplaceAction.
6 7 8 9 10 11 |
# File 'lib/synvert/core/rewriter/action/replace_action.rb', line 6 def initialize(instance, selector, with:) @instance = instance @selector = selector @code = with @node = @instance.current_node end |
Instance Method Details
#begin_pos ⇒ Integer
Begin position of code to replace.
16 17 18 |
# File 'lib/synvert/core/rewriter/action/replace_action.rb', line 16 def begin_pos @node.child_node_range(@selector).begin_pos end |
#end_pos ⇒ Integer
End position of code to replace.
23 24 25 |
# File 'lib/synvert/core/rewriter/action/replace_action.rb', line 23 def end_pos @node.child_node_range(@selector).end_pos end |
#rewritten_code ⇒ String
The rewritten source code.
30 31 32 |
# File 'lib/synvert/core/rewriter/action/replace_action.rb', line 30 def rewritten_code rewritten_source end |