Sha256: 15694570f208965434eb76bf224675b7cf02dc270189a725ac3e2d16b15e0cfd

Contents?: true

Size: 634 Bytes

Versions: 14

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

module Synvert::Core
  # ReplaceAction to replace child node with code.
  class Rewriter::ReplaceAction < Rewriter::Action
    def initialize(instance, *selectors, with:)
      super(instance, with)
      @selectors = selectors
    end

    def calculate_position
      @begin_pos = @selectors.map { |selector| @node.child_node_range(selector).begin_pos }.min
      @end_pos = @selectors.map { |selector| @node.child_node_range(selector).end_pos }.max
    end

    # The rewritten source code.
    #
    # @return [String] rewritten code.
    def rewritten_code
      rewritten_source
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
synvert-core-0.63.1 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.63.0 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.62.1 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.62.0 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.61.2 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.61.1 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.61.0 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.60.0 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.59.0 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.58.3 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.58.2 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.58.0 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.57.1 lib/synvert/core/rewriter/action/replace_action.rb
synvert-core-0.57.0 lib/synvert/core/rewriter/action/replace_action.rb