Class: Synvert::Core::Rewriter::AppendAction

Inherits:
Action
  • Object
show all
Defined in:
lib/synvert/core/rewriter/action.rb

Overview

AppendWithAction to append code to the bottom of node body.

Instance Method Summary collapse

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_posInteger

Begin position to append code.

Returns:

  • (Integer)

    begin position.



99
100
101
102
103
104
105
# File 'lib/synvert/core/rewriter/action.rb', line 99

def begin_pos
  if :begin == @node.type
    @node.loc.expression.end_pos
  else
    @node.loc.expression.end_pos - @node.indent - 4
  end
end

#end_posInteger

End position, always same to begin position.

Returns:

  • (Integer)

    end position.



110
111
112
# File 'lib/synvert/core/rewriter/action.rb', line 110

def end_pos
  begin_pos
end