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



2609
2610
2611
2612
2613
2614
# File 'lib/yarp/node.rb', line 2609

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



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

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



2603
2604
2605
# File 'lib/yarp/node.rb', line 2603

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



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

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2617
2618
2619
# File 'lib/yarp/node.rb', line 2617

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]



2622
2623
2624
# File 'lib/yarp/node.rb', line 2622

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



2630
2631
2632
# File 'lib/yarp/node.rb', line 2630

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

#nameObject

def name: () -> String



2635
2636
2637
# File 'lib/yarp/node.rb', line 2635

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



2640
2641
2642
# File 'lib/yarp/node.rb', line 2640

def operator
  operator_loc.slice
end