class Synvert::Core::Rewriter::ReplaceWithAction
ReplaceWithAction
to replace code.
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_with_action.rb, line 9 def begin_pos @node.loc.expression.begin_pos end
end_pos()
click to toggle source
End position of code to replace.
@return [Integer] end position.
# File lib/synvert/core/rewriter/action/replace_with_action.rb, line 16 def end_pos @node.loc.expression.end_pos end
rewritten_code()
click to toggle source
The rewritten source code with proper indent.
@return [String] rewritten code.
# File lib/synvert/core/rewriter/action/replace_with_action.rb, line 23 def rewritten_code if rewritten_source.include?("\n") new_code = [] rewritten_source.split("\n").each_with_index do |line, index| new_code << (index == 0 ? line : indent + line) end new_code.join("\n") else rewritten_source end end
Private Instance Methods
indent()
click to toggle source
Indent of the node
@return [String] n times whitesphace
# File lib/synvert/core/rewriter/action/replace_with_action.rb, line 40 def indent ' ' * @node.column end