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.



9071
9072
9073
9074
9075
9076
9077
# File 'lib/prism/node.rb', line 9071

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



9113
9114
9115
# File 'lib/prism/node.rb', line 9113

def name
  @name
end

Class Method Details

.typeObject

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



9126
9127
9128
# File 'lib/prism/node.rb', line 9126

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.



9132
9133
9134
9135
# File 'lib/prism/node.rb', line 9132

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



9080
9081
9082
# File 'lib/prism/node.rb', line 9080

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

#child_nodesObject Also known as: deconstruct

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



9085
9086
9087
# File 'lib/prism/node.rb', line 9085

def child_nodes
  []
end

#comment_targetsObject

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



9095
9096
9097
# File 'lib/prism/node.rb', line 9095

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



9090
9091
9092
# File 'lib/prism/node.rb', line 9090

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



9100
9101
9102
# File 'lib/prism/node.rb', line 9100

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 }



9108
9109
9110
# File 'lib/prism/node.rb', line 9108

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

#inspectObject

def inspect -> String



9116
9117
9118
# File 'lib/prism/node.rb', line 9116

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



9121
9122
9123
# File 'lib/prism/node.rb', line 9121

def type
  :instance_variable_target_node
end