class Synvert::Core::Rewriter::DeleteAction

DeleteAction to delete child nodes.

Public Class Methods

new(instance, *selectors) click to toggle source
Calls superclass method Synvert::Core::Rewriter::Action::new
# File lib/synvert/core/rewriter/action/delete_action.rb, line 6
def initialize(instance, *selectors)
  super(instance, nil)
  @selectors = selectors
end

Public Instance Methods

begin_pos() click to toggle source

Begin position of code to delete.

@return [Integer] begin position.

# File lib/synvert/core/rewriter/action/delete_action.rb, line 14
def begin_pos
  pos = @selectors.map { |selector| @node.child_node_range(selector) }.compact.map(&:begin_pos).min
  if @instance.file_source[pos - 1] == ' ' && @instance.file_source[end_pos] == ' '
    pos - 1
  else
    pos
  end
end
end_pos() click to toggle source

End position of code to delete.

@return [Integer] end position.

# File lib/synvert/core/rewriter/action/delete_action.rb, line 26
def end_pos
  @selectors.map { |selector| @node.child_node_range(selector) }.compact.map(&:end_pos).max
end
rewritten_code() click to toggle source

The rewritten code, always empty string.

# File lib/synvert/core/rewriter/action/delete_action.rb, line 31
def rewritten_code
  ''
end