Class: Prism::InstanceVariableTargetNode

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

Overview

Represents writing to an instance 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) ⇒ InstanceVariableTargetNode

Initialize a new InstanceVariableTargetNode node.



10288
10289
10290
10291
10292
10293
10294
# File 'lib/prism/node.rb', line 10288

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



10330
10331
10332
# File 'lib/prism/node.rb', line 10330

def name
  @name
end

Class Method Details

.typeObject

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



10343
10344
10345
# File 'lib/prism/node.rb', line 10343

def self.type
  :instance_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.



10349
10350
10351
10352
# File 'lib/prism/node.rb', line 10349

def ===(other)
  other.is_a?(InstanceVariableTargetNode) &&
    (name === other.name)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



10297
10298
10299
# File 'lib/prism/node.rb', line 10297

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



10302
10303
10304
# File 'lib/prism/node.rb', line 10302

def child_nodes
  []
end

#comment_targetsObject

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



10312
10313
10314
# File 'lib/prism/node.rb', line 10312

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



10307
10308
10309
# File 'lib/prism/node.rb', line 10307

def compact_child_nodes
  []
end

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

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



10317
10318
10319
# File 'lib/prism/node.rb', line 10317

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

#deconstruct_keys(keys) ⇒ Object

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



10325
10326
10327
# File 'lib/prism/node.rb', line 10325

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

#inspectObject

def inspect -> String



10333
10334
10335
# File 'lib/prism/node.rb', line 10333

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



10338
10339
10340
# File 'lib/prism/node.rb', line 10338

def type
  :instance_variable_target_node
end