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



1421
1422
1423
1424
1425
1426
# File 'lib/yarp/node.rb', line 1421

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



1412
1413
1414
# File 'lib/yarp/node.rb', line 1412

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1415
1416
1417
# File 'lib/yarp/node.rb', line 1415

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1418
1419
1420
# File 'lib/yarp/node.rb', line 1418

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



1442
1443
1444
# File 'lib/yarp/node.rb', line 1442

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

#nameObject

def name: () -> String



1447
1448
1449
# File 'lib/yarp/node.rb', line 1447

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



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

def operator
  operator_loc.slice
end