Class: Prism::ConstantReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ConstantReadNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
ext/prism/api_node.c
Overview
Represents referencing a constant.
Foo
^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the [constant](github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
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.
-
#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) -> ConstantReadNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }.
-
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#full_name ⇒ Object
Returns the full name of this constant.
-
#full_name_parts ⇒ Object
Returns the list of parts for the full name of this constant.
-
#initialize(source, node_id, location, flags, name) ⇒ ConstantReadNode
constructor
Initialize a new ConstantReadNode 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) ⇒ ConstantReadNode
Initialize a new ConstantReadNode node.
5996 5997 5998 5999 6000 6001 6002 |
# File 'lib/prism/node.rb', line 5996 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 [constant](github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
X # name `:X`
SOME_CONSTANT # name `:SOME_CONSTANT`
6048 6049 6050 |
# File 'lib/prism/node.rb', line 6048 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
6061 6062 6063 |
# File 'lib/prism/node.rb', line 6061 def self.type :constant_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.
6067 6068 6069 6070 |
# File 'lib/prism/node.rb', line 6067 def ===(other) other.is_a?(ConstantReadNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
6005 6006 6007 |
# File 'lib/prism/node.rb', line 6005 def accept(visitor) visitor.visit_constant_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
6010 6011 6012 |
# File 'lib/prism/node.rb', line 6010 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6026 6027 6028 |
# File 'lib/prism/node.rb', line 6026 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
6021 6022 6023 |
# File 'lib/prism/node.rb', line 6021 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) -> ConstantReadNode
6031 6032 6033 |
# File 'lib/prism/node.rb', line 6031 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ConstantReadNode.new(source, node_id, location, flags, name) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }
6039 6040 6041 |
# File 'lib/prism/node.rb', line 6039 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name } end |
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
6015 6016 6017 6018 |
# File 'lib/prism/node.rb', line 6015 def each_child_node return to_enum(:each_child_node) unless block_given? end |
#full_name ⇒ Object
Returns the full name of this constant. For example: “Foo”
142 143 144 |
# File 'lib/prism/node_ext.rb', line 142 def full_name name.to_s end |
#full_name_parts ⇒ Object
Returns the list of parts for the full name of this constant. For example: [:Foo]
137 138 139 |
# File 'lib/prism/node_ext.rb', line 137 def full_name_parts [name] end |
#inspect ⇒ Object
def inspect -> String
6051 6052 6053 |
# File 'lib/prism/node.rb', line 6051 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
6056 6057 6058 |
# File 'lib/prism/node.rb', line 6056 def type :constant_read_node end |