Class: Prism::ClassVariableReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ClassVariableReadNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents referencing a class variable.
@@foo
^^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the class 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) -> ClassVariableReadNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }.
-
#initialize(source, node_id, location, flags, name) ⇒ ClassVariableReadNode
constructor
Initialize a new ClassVariableReadNode 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) ⇒ ClassVariableReadNode
Initialize a new ClassVariableReadNode node.
3651 3652 3653 3654 3655 3656 3657 |
# File 'lib/prism/node.rb', line 3651 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 class variable, which is a ‘@@` followed by an [identifier](github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
@@abc # name `:@@abc`
@@_test # name `:@@_test`
3697 3698 3699 |
# File 'lib/prism/node.rb', line 3697 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
3710 3711 3712 |
# File 'lib/prism/node.rb', line 3710 def self.type :class_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.
3716 3717 3718 3719 |
# File 'lib/prism/node.rb', line 3716 def ===(other) other.is_a?(ClassVariableReadNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
3660 3661 3662 |
# File 'lib/prism/node.rb', line 3660 def accept(visitor) visitor.visit_class_variable_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3665 3666 3667 |
# File 'lib/prism/node.rb', line 3665 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
3675 3676 3677 |
# File 'lib/prism/node.rb', line 3675 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
3670 3671 3672 |
# File 'lib/prism/node.rb', line 3670 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) -> ClassVariableReadNode
3680 3681 3682 |
# File 'lib/prism/node.rb', line 3680 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ClassVariableReadNode.new(source, node_id, location, flags, name) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }
3688 3689 3690 |
# File 'lib/prism/node.rb', line 3688 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name } end |
#inspect ⇒ Object
def inspect -> String
3700 3701 3702 |
# File 'lib/prism/node.rb', line 3700 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
3705 3706 3707 |
# File 'lib/prism/node.rb', line 3705 def type :class_variable_read_node end |