Class: Prism::ConstantTargetNode

Inherits:
PrismNode
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, name) ⇒ ConstantTargetNode

Initialize a new ConstantTargetNode node.



5685
5686
5687
5688
5689
5690
5691
# File 'lib/prism/node.rb', line 5685

def initialize(source, node_id, location, flags, name)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



5727
5728
5729
# File 'lib/prism/node.rb', line 5727

def name
  @name
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



5740
5741
5742
# File 'lib/prism/node.rb', line 5740

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.



5746
5747
5748
5749
# File 'lib/prism/node.rb', line 5746

def ===(other)
  other.is_a?(ConstantTargetNode) &&
    (name === other.name)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



5694
5695
5696
# File 'lib/prism/node.rb', line 5694

def accept(visitor)
  visitor.visit_constant_target_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



5699
5700
5701
# File 'lib/prism/node.rb', line 5699

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



5709
5710
5711
# File 'lib/prism/node.rb', line 5709

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



5704
5705
5706
# File 'lib/prism/node.rb', line 5704

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



5714
5715
5716
# File 'lib/prism/node.rb', line 5714

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 }



5722
5723
5724
# File 'lib/prism/node.rb', line 5722

def deconstruct_keys(keys)
  { node_id: node_id, location: location, name: name }
end

#full_nameObject

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_partsObject

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

#inspectObject

def inspect -> String



5730
5731
5732
# File 'lib/prism/node.rb', line 5730

def inspect
  InspectVisitor.compose(self)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



5735
5736
5737
# File 'lib/prism/node.rb', line 5735

def type
  :constant_target_node
end