Class: Synvert::Rewriter::AppendAction

Inherits:
Action
  • Object
show all
Defined in:
lib/synvert/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::Rewriter::Action

Instance Method Details

#begin_posInteger

Begin position to append code.

Returns:

  • (Integer)

    begin position.



97
98
99
100
101
102
103
# File 'lib/synvert/rewriter/action.rb', line 97

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

#end_posInteger

End position, always same to begin position.

Returns:

  • (Integer)

    end position.



108
109
110
# File 'lib/synvert/rewriter/action.rb', line 108

def end_pos
  begin_pos
end