Sha256: 407077d57a026411c2bc8ed46e87df7fe0e2c6124323ade05ea62a82115738e9

Contents?: true

Size: 702 Bytes

Versions: 5

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module Synvert::Core
  # ReplaceErbStmtWithExprAction to replace erb stmt code to expr,
  # @example
  #   e.g. <% form_for ... %> => <%= form_for ... %>.
  class Rewriter::ReplaceErbStmtWithExprAction < NodeMutation::Action
    # Initialize a ReplaceErbStmtWithExprAction.
    #
    # @param node [Synvert::Core::Rewriter::Node]
    def initialize(node)
      super(node, nil)
    end

    # The new erb expr code.
    #
    # @return [String] new code.
    def new_code
      '='
    end

    private

    # Calculate the begin the end positions.
    def calculate_position
      @start = NodeMutation.adapter.get_start(@node) - 1
      @end = @start
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
synvert-core-1.22.1 lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
synvert-core-1.22.0 lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
synvert-core-1.21.7 lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
synvert-core-1.21.6 lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb
synvert-core-1.21.5 lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb