Class: YARP::ConstantOperatorAndWriteNode

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

Overview

Represents the use of the ‘&&=` operator for assignment to a constant.

Target &&= value
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, operator_loc, value, location) ⇒ ConstantOperatorAndWriteNode

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



1437
1438
1439
1440
1441
1442
# File 'lib/yarp/node.rb', line 1437

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

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



1428
1429
1430
# File 'lib/yarp/node.rb', line 1428

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1431
1432
1433
# File 'lib/yarp/node.rb', line 1431

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1434
1435
1436
# File 'lib/yarp/node.rb', line 1434

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1445
1446
1447
# File 'lib/yarp/node.rb', line 1445

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

#child_nodesObject Also known as: deconstruct

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



1451
1452
1453
# File 'lib/yarp/node.rb', line 1451

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



1459
1460
1461
# File 'lib/yarp/node.rb', line 1459

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

#nameObject

def name: () -> String



1464
1465
1466
# File 'lib/yarp/node.rb', line 1464

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



1469
1470
1471
# File 'lib/yarp/node.rb', line 1469

def operator
  operator_loc.slice
end