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



4266
4267
4268
4269
4270
4271
4272
4273
# File 'lib/yarp/node.rb', line 4266

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?



4260
4261
4262
# File 'lib/yarp/node.rb', line 4260

def lparen_loc
  @lparen_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



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

def operator_loc
  @operator_loc
end

#rparen_locObject (readonly)

attr_reader rparen_loc: Location?



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

def rparen_loc
  @rparen_loc
end

#targetsObject (readonly)

attr_reader targets: Array



4251
4252
4253
# File 'lib/yarp/node.rb', line 4251

def targets
  @targets
end

#valueObject (readonly)

attr_reader value: Node?



4257
4258
4259
# File 'lib/yarp/node.rb', line 4257

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



4281
4282
4283
# File 'lib/yarp/node.rb', line 4281

def child_nodes
  [*targets, value]
end

#deconstruct_keys(keys) ⇒ Object

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



4289
4290
4291
# File 'lib/yarp/node.rb', line 4289

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?



4299
4300
4301
# File 'lib/yarp/node.rb', line 4299

def lparen
  lparen_loc&.slice
end

#operatorObject

def operator: () -> String?



4294
4295
4296
# File 'lib/yarp/node.rb', line 4294

def operator
  operator_loc&.slice
end

#rparenObject

def rparen: () -> String?



4304
4305
4306
# File 'lib/yarp/node.rb', line 4304

def rparen
  rparen_loc&.slice
end