Class: YARP::GlobalVariableOperatorWriteNode

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

Overview

Represents assigning to a global variable 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) ⇒ GlobalVariableOperatorWriteNode

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



2714
2715
2716
2717
2718
2719
2720
# File 'lib/yarp/node.rb', line 2714

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



2702
2703
2704
# File 'lib/yarp/node.rb', line 2702

def name_loc
  @name_loc
end

#operatorObject (readonly)

attr_reader operator: Symbol



2711
2712
2713
# File 'lib/yarp/node.rb', line 2711

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



2705
2706
2707
# File 'lib/yarp/node.rb', line 2705

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



2708
2709
2710
# File 'lib/yarp/node.rb', line 2708

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2723
2724
2725
# File 'lib/yarp/node.rb', line 2723

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

#child_nodesObject Also known as: deconstruct

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



2728
2729
2730
# File 'lib/yarp/node.rb', line 2728

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



2736
2737
2738
# File 'lib/yarp/node.rb', line 2736

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

#nameObject

def name: () -> String



2741
2742
2743
# File 'lib/yarp/node.rb', line 2741

def name
  name_loc.slice
end