Class: Prism::ConstantReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ConstantReadNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
sig/generated/prism/node.rbs,
sig/generated/prism/node_ext.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :constant_read_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ⇒ ConstantReadNode
:call-seq: copy(**fields) -> ConstantReadNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#full_name ⇒ String
Returns the full name of this constant.
-
#full_name_parts ⇒ Array[Symbol]
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 ⇒ String
: () -> String.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#type ⇒ :constant_read_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, name) ⇒ ConstantReadNode
Initialize a new ConstantReadNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void
10235 10236 10237 10238 10239 10240 10241 |
# File 'lib/prism/node.rb', line 10235 def initialize(source, node_id, location, flags, name) @source = source @node_id = node_id @location = location @flags = flags @name = name end |
Class Method Details
.type ⇒ :constant_read_node
See Node.type.
: () -> :constant_read_node
10319 10320 10321 |
# File 'lib/prism/node.rb', line 10319 def self.type :constant_read_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
10353 10354 10355 10356 |
# File 'lib/prism/node.rb', line 10353 def ===(other) # :nodoc: other.is_a?(ConstantReadNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
10257 10258 10259 |
# File 'lib/prism/node.rb', line 10257 def accept(visitor) visitor.visit_constant_read_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
10264 10265 10266 |
# File 'lib/prism/node.rb', line 10264 def child_nodes [] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
10280 10281 10282 |
# File 'lib/prism/node.rb', line 10280 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ⇒ ConstantReadNode
:call-seq:
copy(**fields) -> ConstantReadNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantReadNode
10290 10291 10292 |
# File 'lib/prism/node.rb', line 10290 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) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 |
# File 'lib/prism/node.rb', line 10297 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location name]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :name then deconstructed[:name] = self.name end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
10272 10273 10274 10275 |
# File 'lib/prism/node.rb', line 10272 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? end |
#full_name ⇒ String
Returns the full name of this constant. For example: "Foo"
: () -> String
193 194 195 |
# File 'lib/prism/node_ext.rb', line 193 def full_name name.to_s end |
#full_name_parts ⇒ Array[Symbol]
Returns the list of parts for the full name of this constant. For example: [:Foo]
: () -> Array
186 187 188 |
# File 'lib/prism/node_ext.rb', line 186 def full_name_parts [name] end |
#inspect ⇒ String
: () -> String
10324 10325 10326 |
# File 'lib/prism/node.rb', line 10324 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
The name of the constant.
X # name `:X`
SOME_CONSTANT # name `:SOME_CONSTANT`
: () -> Symbol
10344 10345 10346 |
# File 'lib/prism/node.rb', line 10344 def name @name end |
#type ⇒ :constant_read_node
See Node#type.
: () -> :constant_read_node
10312 10313 10314 |
# File 'lib/prism/node.rb', line 10312 def type :constant_read_node end |