Class: Synvert::Core::Rewriter::ReplaceWithAction
- Defined in:
- lib/synvert/core/rewriter/action/replace_with_action.rb
Overview
ReplaceWithAction to replace code.
Constant Summary
Constants inherited from Action
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
-
#rewritten_code ⇒ String
The rewritten source code with proper indent.
Methods inherited from Action
Constructor Details
This class inherits a constructor from Synvert::Core::Rewriter::Action
Instance Method Details
#rewritten_code ⇒ String
The rewritten source code with proper indent.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/synvert/core/rewriter/action/replace_with_action.rb', line 9 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 |