Sha256: f27285b74f840db53a08e4691edc176cef668e6d47a66a59d7ee154662a5ebe3

Contents?: true

Size: 639 Bytes

Versions: 14

Compression:

Stored size: 639 Bytes

Contents

# frozen_string_literal: true

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

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

    # The rewritten code, always empty string.
    def rewritten_code
      ''
    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/delete_action.rb
synvert-core-0.63.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.62.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.62.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.61.2 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.61.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.61.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.60.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.59.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.58.3 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.58.2 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.58.0 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.57.1 lib/synvert/core/rewriter/action/delete_action.rb
synvert-core-0.57.0 lib/synvert/core/rewriter/action/delete_action.rb