Class: Prism::ConstantTargetNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ConstantTargetNode
- 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
Represents writing to a constant in a context that doesn't have an explicit value.
Foo, Bar = baz
^^^ ^^^
Class Method Summary collapse
-
.type ⇒ :constant_target_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) ⇒ ConstantTargetNode
:call-seq: copy(**fields) -> ConstantTargetNode.
-
#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) ⇒ ConstantTargetNode
constructor
Initialize a new ConstantTargetNode node.
-
#inspect ⇒ String
: () -> String.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#type ⇒ :constant_target_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, name) ⇒ ConstantTargetNode
Initialize a new ConstantTargetNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void
10373 10374 10375 10376 10377 10378 10379 |
# File 'lib/prism/node.rb', line 10373 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_target_node
See Node.type.
: () -> :constant_target_node
10457 10458 10459 |
# File 'lib/prism/node.rb', line 10457 def self.type :constant_target_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
10483 10484 10485 10486 |
# File 'lib/prism/node.rb', line 10483 def ===(other) # :nodoc: other.is_a?(ConstantTargetNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
10395 10396 10397 |
# File 'lib/prism/node.rb', line 10395 def accept(visitor) visitor.visit_constant_target_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
10402 10403 10404 |
# File 'lib/prism/node.rb', line 10402 def child_nodes [] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
10418 10419 10420 |
# File 'lib/prism/node.rb', line 10418 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ⇒ ConstantTargetNode
:call-seq:
copy(**fields) -> ConstantTargetNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantTargetNode
10428 10429 10430 |
# File 'lib/prism/node.rb', line 10428 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ConstantTargetNode.new(source, node_id, location, flags, name) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 |
# File 'lib/prism/node.rb', line 10435 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
10410 10411 10412 10413 |
# File 'lib/prism/node.rb', line 10410 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
306 307 308 |
# File 'lib/prism/node_ext.rb', line 306 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
299 300 301 |
# File 'lib/prism/node_ext.rb', line 299 def full_name_parts [name] end |
#inspect ⇒ String
: () -> String
10462 10463 10464 |
# File 'lib/prism/node.rb', line 10462 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Returns the name attribute.
: () -> Symbol
10474 10475 10476 |
# File 'lib/prism/node.rb', line 10474 def name @name end |
#type ⇒ :constant_target_node
See Node#type.
: () -> :constant_target_node
10450 10451 10452 |
# File 'lib/prism/node.rb', line 10450 def type :constant_target_node end |