Class: YARP::MultiWriteNode

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

Overview

Represents a multi-target expression.

a, b, c = 1, 2, 3
^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(targets, operator_loc, value, lparen_loc, rparen_loc, location) ⇒ MultiWriteNode

def initialize: (targets: Array, operator_loc: Location?, value: Node?, lparen_loc: Location?, rparen_loc: Location?, location: Location) -> void



4238
4239
4240
4241
4242
4243
4244
4245
# File 'lib/yarp/node.rb', line 4238

def initialize(targets, operator_loc, value, lparen_loc, rparen_loc, location)
  @targets = targets
  @operator_loc = operator_loc
  @value = value
  @lparen_loc = lparen_loc
  @rparen_loc = rparen_loc
  @location = location
end

Instance Attribute Details

#lparen_locObject (readonly)

attr_reader lparen_loc: Location?



4232
4233
4234
# File 'lib/yarp/node.rb', line 4232

def lparen_loc
  @lparen_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



4226
4227
4228
# File 'lib/yarp/node.rb', line 4226

def operator_loc
  @operator_loc
end

#rparen_locObject (readonly)

attr_reader rparen_loc: Location?



4235
4236
4237
# File 'lib/yarp/node.rb', line 4235

def rparen_loc
  @rparen_loc
end

#targetsObject (readonly)

attr_reader targets: Array



4223
4224
4225
# File 'lib/yarp/node.rb', line 4223

def targets
  @targets
end

#valueObject (readonly)

attr_reader value: Node?



4229
4230
4231
# File 'lib/yarp/node.rb', line 4229

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4248
4249
4250
# File 'lib/yarp/node.rb', line 4248

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

#child_nodesObject Also known as: deconstruct

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



4254
4255
4256
# File 'lib/yarp/node.rb', line 4254

def child_nodes
  [*targets, value]
end

#deconstruct_keys(keys) ⇒ Object

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



4262
4263
4264
# File 'lib/yarp/node.rb', line 4262

def deconstruct_keys(keys)
  { targets: targets, operator_loc: operator_loc, value: value, lparen_loc: lparen_loc, rparen_loc: rparen_loc, location: location }
end

#lparenObject

def lparen: () -> String?



4272
4273
4274
# File 'lib/yarp/node.rb', line 4272

def lparen
  lparen_loc&.slice
end

#operatorObject

def operator: () -> String?



4267
4268
4269
# File 'lib/yarp/node.rb', line 4267

def operator
  operator_loc&.slice
end

#rparenObject

def rparen: () -> String?



4277
4278
4279
# File 'lib/yarp/node.rb', line 4277

def rparen
  rparen_loc&.slice
end