Class: Synvert::Core::Rewriter::PrependAction
- Defined in:
- lib/synvert/core/rewriter/action/prepend_action.rb
Overview
PrependAction to prepend code to the top of node body.
Constant Summary collapse
- DO_LENGTH =
' do'.length
Constants inherited from Action
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
Methods inherited from Action
#initialize, #line, #process, #rewritten_code
Constructor Details
This class inherits a constructor from Synvert::Core::Rewriter::Action
Instance Method Details
#calculate_position ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/synvert/core/rewriter/action/prepend_action.rb', line 8 def calculate_position @begin_pos = case @node.type when :block if @node.children[1].children.empty? @node.children[0].loc.expression.end_pos + DO_LENGTH else @node.children[1].loc.expression.end_pos end when :class @node.children[1] ? @node.children[1].loc.expression.end_pos : @node.children[0].loc.expression.end_pos else @node.children.last.loc.expression.end_pos end @end_pos = @begin_pos end |