Class: Prism::ConstantTargetNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ConstantTargetNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
ext/prism/api_node.c
Overview
Represents writing to a constant in a context that doesn’t have an explicit value.
Foo, Bar = baz
^^^ ^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
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) -> ConstantTargetNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }.
-
#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) ⇒ ConstantTargetNode
constructor
Initialize a new ConstantTargetNode 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) ⇒ ConstantTargetNode
Initialize a new ConstantTargetNode node.
4911 4912 4913 4914 4915 4916 4917 |
# File 'lib/prism/node.rb', line 4911 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)
attr_reader name: Symbol
4953 4954 4955 |
# File 'lib/prism/node.rb', line 4953 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
4966 4967 4968 |
# File 'lib/prism/node.rb', line 4966 def self.type :constant_target_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.
4972 4973 4974 4975 |
# File 'lib/prism/node.rb', line 4972 def ===(other) other.is_a?(ConstantTargetNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
4920 4921 4922 |
# File 'lib/prism/node.rb', line 4920 def accept(visitor) visitor.visit_constant_target_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4925 4926 4927 |
# File 'lib/prism/node.rb', line 4925 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
4935 4936 4937 |
# File 'lib/prism/node.rb', line 4935 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
4930 4931 4932 |
# File 'lib/prism/node.rb', line 4930 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) -> ConstantTargetNode
4940 4941 4942 |
# File 'lib/prism/node.rb', line 4940 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) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }
4948 4949 4950 |
# File 'lib/prism/node.rb', line 4948 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name } end |
#full_name ⇒ Object
Returns the full name of this constant. For example: “Foo”
262 263 264 |
# File 'lib/prism/node_ext.rb', line 262 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]
257 258 259 |
# File 'lib/prism/node_ext.rb', line 257 def full_name_parts [name] end |
#inspect ⇒ Object
def inspect -> String
4956 4957 4958 |
# File 'lib/prism/node.rb', line 4956 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
4961 4962 4963 |
# File 'lib/prism/node.rb', line 4961 def type :constant_target_node end |