Class: YARP::GlobalVariableOperatorAndWriteNode

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 global variable.

$target &&= value
^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



2593
2594
2595
2596
2597
2598
# File 'lib/yarp/node.rb', line 2593

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



2584
2585
2586
# File 'lib/yarp/node.rb', line 2584

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



2587
2588
2589
# File 'lib/yarp/node.rb', line 2587

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



2590
2591
2592
# File 'lib/yarp/node.rb', line 2590

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2601
2602
2603
# File 'lib/yarp/node.rb', line 2601

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

#child_nodesObject Also known as: deconstruct

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



2607
2608
2609
# File 'lib/yarp/node.rb', line 2607

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



2615
2616
2617
# File 'lib/yarp/node.rb', line 2615

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

#nameObject

def name: () -> String



2620
2621
2622
# File 'lib/yarp/node.rb', line 2620

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



2625
2626
2627
# File 'lib/yarp/node.rb', line 2625

def operator
  operator_loc.slice
end