Class: YARP::ClassVariableOperatorAndWriteNode

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

@@target &&= value
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



1189
1190
1191
1192
1193
1194
# File 'lib/yarp/node.rb', line 1189

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



1180
1181
1182
# File 'lib/yarp/node.rb', line 1180

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1183
1184
1185
# File 'lib/yarp/node.rb', line 1183

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1186
1187
1188
# File 'lib/yarp/node.rb', line 1186

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1197
1198
1199
# File 'lib/yarp/node.rb', line 1197

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

#child_nodesObject Also known as: deconstruct

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



1202
1203
1204
# File 'lib/yarp/node.rb', line 1202

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



1210
1211
1212
# File 'lib/yarp/node.rb', line 1210

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

#nameObject

def name: () -> String



1215
1216
1217
# File 'lib/yarp/node.rb', line 1215

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



1220
1221
1222
# File 'lib/yarp/node.rb', line 1220

def operator
  operator_loc.slice
end