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.



10876
10877
10878
10879
10880
10881
10882
10883
# File 'lib/prism/node.rb', line 10876

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



10922
10923
10924
# File 'lib/prism/node.rb', line 10922

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



10919
10920
10921
# File 'lib/prism/node.rb', line 10919

def name
  @name
end

Class Method Details

.typeObject

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



10935
10936
10937
# File 'lib/prism/node.rb', line 10935

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.



10941
10942
10943
10944
10945
# File 'lib/prism/node.rb', line 10941

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



10891
10892
10893
# File 'lib/prism/node.rb', line 10891

def child_nodes
  []
end

#comment_targetsObject

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



10901
10902
10903
# File 'lib/prism/node.rb', line 10901

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



10896
10897
10898
# File 'lib/prism/node.rb', line 10896

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



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

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 }



10914
10915
10916
# File 'lib/prism/node.rb', line 10914

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

#inspectObject

def inspect -> String



10925
10926
10927
# File 'lib/prism/node.rb', line 10925

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



10930
10931
10932
# File 'lib/prism/node.rb', line 10930

def type
  :local_variable_target_node
end