Class: NodeMutation::DeleteAction

Inherits:
Action
  • Object
show all
Defined in:
lib/node_mutation/action/delete_action.rb

Overview

DeleteAction deletes child nodes.

Instance Attribute Summary

Attributes inherited from Action

#actions, #end, #start, #type

Instance Method Summary collapse

Methods inherited from Action

#process, #to_struct

Constructor Details

#initialize(node, *selectors, adapter:, and_comma: false) ⇒ DeleteAction

Initialize a DeleteAction.

Parameters:

  • node (Node)
  • selectors (Array<Symbol, String>)

    used to select child nodes

  • and_comma (Boolean) (defaults to: false)

    delete extra comma.

  • adapter (NodeMutation::Adapter)


11
12
13
14
15
16
# File 'lib/node_mutation/action/delete_action.rb', line 11

def initialize(node, *selectors, adapter:, and_comma: false)
  super(node, nil, adapter: adapter)
  @selectors = selectors
  @and_comma = and_comma
  @type = :delete
end

Instance Method Details

#new_codeObject

The rewritten code, always empty string.



19
20
21
# File 'lib/node_mutation/action/delete_action.rb', line 19

def new_code
  ''
end