Class: YARP::ClassVariableOperatorWriteNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents assigning to a class variable using an operator that isn’t ‘=`.

@@target += value
^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, name_loc, operator_loc, value, operator, location) ⇒ ClassVariableOperatorWriteNode

def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, operator: Symbol, location: Location) -> void



1489
1490
1491
1492
1493
1494
1495
1496
# File 'lib/yarp/node.rb', line 1489

def initialize(name, name_loc, operator_loc, value, operator, location)
  @name = name
  @name_loc = name_loc
  @operator_loc = operator_loc
  @value = value
  @operator = operator
  @location = location
end

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



1474
1475
1476
# File 'lib/yarp/node.rb', line 1474

def name
  @name
end

#name_locObject (readonly)

attr_reader name_loc: Location



1477
1478
1479
# File 'lib/yarp/node.rb', line 1477

def name_loc
  @name_loc
end

#operatorObject (readonly)

attr_reader operator: Symbol



1486
1487
1488
# File 'lib/yarp/node.rb', line 1486

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1480
1481
1482
# File 'lib/yarp/node.rb', line 1480

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1483
1484
1485
# File 'lib/yarp/node.rb', line 1483

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1499
1500
1501
# File 'lib/yarp/node.rb', line 1499

def accept(visitor)
  visitor.visit_class_variable_operator_write_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



1504
1505
1506
# File 'lib/yarp/node.rb', line 1504

def child_nodes
  [value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ClassVariableOperatorWriteNode



1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
# File 'lib/yarp/node.rb', line 1509

def copy(**params)
  ClassVariableOperatorWriteNode.new(
    params.fetch(:name) { name },
    params.fetch(:name_loc) { name_loc },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:value) { value },
    params.fetch(:operator) { operator },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



1524
1525
1526
# File 'lib/yarp/node.rb', line 1524

def deconstruct_keys(keys)
  { name: name, name_loc: name_loc, operator_loc: operator_loc, value: value, operator: operator, location: location }
end