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
^^^  ^^^

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.



10839
10840
10841
10842
10843
10844
10845
10846
# File 'lib/prism/node.rb', line 10839

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



10885
10886
10887
# File 'lib/prism/node.rb', line 10885

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



10882
10883
10884
# File 'lib/prism/node.rb', line 10882

def name
  @name
end

Class Method Details

.typeObject

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



10898
10899
10900
# File 'lib/prism/node.rb', line 10898

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.



10904
10905
10906
10907
10908
# File 'lib/prism/node.rb', line 10904

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



10849
10850
10851
# File 'lib/prism/node.rb', line 10849

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

#child_nodesObject Also known as: deconstruct

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



10854
10855
10856
# File 'lib/prism/node.rb', line 10854

def child_nodes
  []
end

#comment_targetsObject

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



10864
10865
10866
# File 'lib/prism/node.rb', line 10864

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



10859
10860
10861
# File 'lib/prism/node.rb', line 10859

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



10869
10870
10871
# File 'lib/prism/node.rb', line 10869

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 }



10877
10878
10879
# File 'lib/prism/node.rb', line 10877

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

#inspectObject

def inspect -> String



10888
10889
10890
# File 'lib/prism/node.rb', line 10888

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



10893
10894
10895
# File 'lib/prism/node.rb', line 10893

def type
  :local_variable_target_node
end