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.



12129
12130
12131
12132
12133
12134
12135
12136
# File 'lib/prism/node.rb', line 12129

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



12175
12176
12177
# File 'lib/prism/node.rb', line 12175

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



12172
12173
12174
# File 'lib/prism/node.rb', line 12172

def name
  @name
end

Class Method Details

.typeObject

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



12188
12189
12190
# File 'lib/prism/node.rb', line 12188

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.



12194
12195
12196
12197
12198
# File 'lib/prism/node.rb', line 12194

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



12139
12140
12141
# File 'lib/prism/node.rb', line 12139

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

#child_nodesObject Also known as: deconstruct

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



12144
12145
12146
# File 'lib/prism/node.rb', line 12144

def child_nodes
  []
end

#comment_targetsObject

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



12154
12155
12156
# File 'lib/prism/node.rb', line 12154

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



12149
12150
12151
# File 'lib/prism/node.rb', line 12149

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



12159
12160
12161
# File 'lib/prism/node.rb', line 12159

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 }



12167
12168
12169
# File 'lib/prism/node.rb', line 12167

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

#inspectObject

def inspect -> String



12178
12179
12180
# File 'lib/prism/node.rb', line 12178

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



12183
12184
12185
# File 'lib/prism/node.rb', line 12183

def type
  :local_variable_target_node
end