Class: YARP::ConstantOperatorWriteNode

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

Overview

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

Target += value
^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, operator_loc, value, operator, location) ⇒ ConstantOperatorWriteNode

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



1544
1545
1546
1547
1548
1549
1550
# File 'lib/yarp/node.rb', line 1544

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

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



1532
1533
1534
# File 'lib/yarp/node.rb', line 1532

def name_loc
  @name_loc
end

#operatorObject (readonly)

attr_reader operator: Symbol



1541
1542
1543
# File 'lib/yarp/node.rb', line 1541

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1535
1536
1537
# File 'lib/yarp/node.rb', line 1535

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1538
1539
1540
# File 'lib/yarp/node.rb', line 1538

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1553
1554
1555
# File 'lib/yarp/node.rb', line 1553

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

#child_nodesObject Also known as: deconstruct

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



1559
1560
1561
# File 'lib/yarp/node.rb', line 1559

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



1567
1568
1569
# File 'lib/yarp/node.rb', line 1567

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

#nameObject

def name: () -> String



1572
1573
1574
# File 'lib/yarp/node.rb', line 1572

def name
  name_loc.slice
end