Class: Synvert::Rewriter::ReplaceWithAction
- Defined in:
- lib/synvert/rewriter/action.rb
Overview
ReplaceWithAction to replace code.
Instance Method Summary collapse
-
#begin_pos ⇒ Integer
Begin position of code to replace.
-
#end_pos ⇒ Integer
End position of code to replace.
-
#rewritten_code ⇒ String
The rewritten source code with proper indent.
Methods inherited from Action
#<=>, #initialize, #line, #rewritten_source
Constructor Details
This class inherits a constructor from Synvert::Rewriter::Action
Instance Method Details
#begin_pos ⇒ Integer
Begin position of code to replace.
57 58 59 |
# File 'lib/synvert/rewriter/action.rb', line 57 def begin_pos @node.loc.expression.begin_pos end |
#end_pos ⇒ Integer
End position of code to replace.
64 65 66 |
# File 'lib/synvert/rewriter/action.rb', line 64 def end_pos @node.loc.expression.end_pos end |
#rewritten_code ⇒ String
The rewritten source code with proper indent.
71 72 73 74 75 76 77 78 79 |
# File 'lib/synvert/rewriter/action.rb', line 71 def rewritten_code if rewritten_source.split("\n").length > 1 "\n\n" + rewritten_source.split("\n").map { |line| indent(@node) + line }.join("\n") else rewritten_source end end |