Class: Prism::LocalVariableTargetNode

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

Overview

Represents writing to a local variable in a context that doesn’t have an explicit value.

foo, bar = baz
^^^  ^^^

foo => baz
       ^^^

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, name, depth) ⇒ LocalVariableTargetNode

Initialize a new LocalVariableTargetNode node.



12234
12235
12236
12237
12238
12239
12240
12241
# File 'lib/prism/node.rb', line 12234

def initialize(source, node_id, location, flags, name, depth)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @name = name
  @depth = depth
end

Instance Attribute Details

#depthObject (readonly)

attr_reader depth: Integer



12280
12281
12282
# File 'lib/prism/node.rb', line 12280

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



12277
12278
12279
# File 'lib/prism/node.rb', line 12277

def name
  @name
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



12293
12294
12295
# File 'lib/prism/node.rb', line 12293

def self.type
  :local_variable_target_node
end

Instance Method Details

#===(other) ⇒ Object

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.



12299
12300
12301
12302
12303
# File 'lib/prism/node.rb', line 12299

def ===(other)
  other.is_a?(LocalVariableTargetNode) &&
    (name === other.name) &&
    (depth === other.depth)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



12244
12245
12246
# File 'lib/prism/node.rb', line 12244

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



12249
12250
12251
# File 'lib/prism/node.rb', line 12249

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



12259
12260
12261
# File 'lib/prism/node.rb', line 12259

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



12254
12255
12256
# File 'lib/prism/node.rb', line 12254

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, depth: self.depth) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableTargetNode



12264
12265
12266
# File 'lib/prism/node.rb', line 12264

def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, depth: self.depth)
  LocalVariableTargetNode.new(source, node_id, location, flags, name, depth)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol, depth: Integer }



12272
12273
12274
# File 'lib/prism/node.rb', line 12272

def deconstruct_keys(keys)
  { node_id: node_id, location: location, name: name, depth: depth }
end

#inspectObject

def inspect -> String



12283
12284
12285
# File 'lib/prism/node.rb', line 12283

def inspect
  InspectVisitor.compose(self)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



12288
12289
12290
# File 'lib/prism/node.rb', line 12288

def type
  :local_variable_target_node
end