Class: Synvert::Core::Rewriter::InsertAction
- Defined in:
- lib/synvert/core/rewriter/action/insert_action.rb
Overview
InsertAction to insert code to the top of node body.
Constant Summary collapse
- DO_LENGTH =
" do".length
Constants inherited from Action
Action::DEFAULT_INDENT, Action::DEFAULT_OPTIONS
Instance Method Summary collapse
-
#begin_pos ⇒ Integer
Begin position to insert code.
-
#end_pos ⇒ Integer
End position, always same to begin position.
Methods inherited from Action
#initialize, #line, #rewritten_code, #rewritten_source
Constructor Details
This class inherits a constructor from Synvert::Core::Rewriter::Action
Instance Method Details
#begin_pos ⇒ Integer
Begin position to insert code.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/synvert/core/rewriter/action/insert_action.rb', line 11 def begin_pos case @node.type when :block @node.children[1].children.empty? ? @node.children[0].loc.expression.end_pos + DO_LENGTH : @node.children[1].loc.expression.end_pos 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 |
#end_pos ⇒ Integer
End position, always same to begin position.
25 26 27 |
# File 'lib/synvert/core/rewriter/action/insert_action.rb', line 25 def end_pos begin_pos end |