Class: Prism::InstanceVariableReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::InstanceVariableReadNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents referencing an instance variable.
@foo
^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the instance variable, which is a ‘@` followed by an [identifier](github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#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) -> InstanceVariableReadNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }.
-
#initialize(source, node_id, location, flags, name) ⇒ InstanceVariableReadNode
constructor
Initialize a new InstanceVariableReadNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name) ⇒ InstanceVariableReadNode
Initialize a new InstanceVariableReadNode node.
8994 8995 8996 8997 8998 8999 9000 |
# File 'lib/prism/node.rb', line 8994 def initialize(source, node_id, location, flags, name) @source = source @node_id = node_id @location = location @flags = flags @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the instance variable, which is a ‘@` followed by an [identifier](github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
@x # name `:@x`
@_test # name `:@_test`
9040 9041 9042 |
# File 'lib/prism/node.rb', line 9040 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
9053 9054 9055 |
# File 'lib/prism/node.rb', line 9053 def self.type :instance_variable_read_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.
9059 9060 9061 9062 |
# File 'lib/prism/node.rb', line 9059 def ===(other) other.is_a?(InstanceVariableReadNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
9003 9004 9005 |
# File 'lib/prism/node.rb', line 9003 def accept(visitor) visitor.visit_instance_variable_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
9008 9009 9010 |
# File 'lib/prism/node.rb', line 9008 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
9018 9019 9020 |
# File 'lib/prism/node.rb', line 9018 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
9013 9014 9015 |
# File 'lib/prism/node.rb', line 9013 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) -> InstanceVariableReadNode
9023 9024 9025 |
# File 'lib/prism/node.rb', line 9023 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) InstanceVariableReadNode.new(source, node_id, location, flags, name) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }
9031 9032 9033 |
# File 'lib/prism/node.rb', line 9031 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name } end |
#inspect ⇒ Object
def inspect -> String
9043 9044 9045 |
# File 'lib/prism/node.rb', line 9043 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
9048 9049 9050 |
# File 'lib/prism/node.rb', line 9048 def type :instance_variable_read_node end |