class Synvert::Core::Rewriter::ReplaceAction
ReplaceAction
to replace child node with code.
Public Class Methods
new(instance, *selectors, with:)
click to toggle source
Calls superclass method
Synvert::Core::Rewriter::Action::new
# File lib/synvert/core/rewriter/action/replace_action.rb, line 6 def initialize(instance, *selectors, with:) super(instance, with) @selectors = selectors end
Public Instance Methods
begin_pos()
click to toggle source
Begin position of code to replace.
@return [Integer] begin position.
# File lib/synvert/core/rewriter/action/replace_action.rb, line 14 def begin_pos @selectors.map { |selector| @node.child_node_range(selector).begin_pos }.min end
end_pos()
click to toggle source
End position of code to replace.
@return [Integer] end position.
# File lib/synvert/core/rewriter/action/replace_action.rb, line 21 def end_pos @selectors.map { |selector| @node.child_node_range(selector).end_pos }.max end
rewritten_code()
click to toggle source
The rewritten source code.
@return [String] rewritten code.
# File lib/synvert/core/rewriter/action/replace_action.rb, line 28 def rewritten_code rewritten_source end