Sha256: 89034a537c4d52b01bb7042677eb1a47cd0c633175d442acb6e5ad58a7ca66b9

Contents?: true

Size: 724 Bytes

Versions: 26

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

module Synvert::Core
  # RemoveAction to delete code.
  class Rewriter::DeleteAction < Rewriter::Action
    def initialize(instance, *selectors)
      super(instance, nil)
      @selectors = selectors
    end

    # Begin position of code to replace.
    #
    # @return [Integer] begin position.
    def begin_pos
      @selectors.map { |selector| @node.child_node_range(selector).begin_pos }.min
    end

    # End position of code to replace.
    #
    # @return [Integer] end position.
    def end_pos
      @selectors.map { |selector| @node.child_node_range(selector).end_pos }.max
    end

    # The rewritten code, always empty string.
    def rewritten_code
      ''
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
synvert-core-0.44.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.42.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.42.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.41.2 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.41.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.41.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.40.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.39.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.38.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.36.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.35.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.35.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.34.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.33.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.33.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.32.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.31.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.30.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.29.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.28.1 lib/synvert/core/rewriter/action/delete_action.rb