Class: Synvert::Core::Rewriter::ReplaceErbStmtWithExprAction

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

Overview

ReplaceErbStmtWithExprAction to replace erb stmt code to expr,

Examples:

e.g. <% form_for ... %> => <%= form_for ... %>.

Instance Method Summary collapse

Constructor Details

#initialize(node, erb_source, adapter:) ⇒ ReplaceErbStmtWithExprAction

Initialize a ReplaceErbStmtWithExprAction.

Parameters:

  • node (Synvert::Core::Rewriter::Node)
  • erb_source (String)
  • adapter (NodeMutation::Adapter)


13
14
15
16
17
# File 'lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb', line 13

def initialize(node, erb_source, adapter:)
  super(node, nil, adapter: adapter)
  @erb_source = erb_source
  @type = :insert
end

Instance Method Details

#new_codeString

The new erb expr code.

Returns:

  • (String)

    new code.



22
23
24
# File 'lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb', line 22

def new_code
  '='
end