Class: Prism::ClassVariableTargetNode

Inherits:
PrismNode
  • Object
show all
Defined in:
lib/prism/node.rb,
ext/prism/api_node.c

Overview

Represents writing to a class variable 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) ⇒ ClassVariableTargetNode

Initialize a new ClassVariableTargetNode node.



4714
4715
4716
4717
4718
4719
4720
# File 'lib/prism/node.rb', line 4714

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



4762
4763
4764
# File 'lib/prism/node.rb', line 4762

def name
  @name
end

Class Method Details

.typeObject

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



4775
4776
4777
# File 'lib/prism/node.rb', line 4775

def self.type
  :class_variable_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.



4781
4782
4783
4784
# File 'lib/prism/node.rb', line 4781

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



4723
4724
4725
# File 'lib/prism/node.rb', line 4723

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



4728
4729
4730
# File 'lib/prism/node.rb', line 4728

def child_nodes
  []
end

#comment_targetsObject

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



4744
4745
4746
# File 'lib/prism/node.rb', line 4744

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



4739
4740
4741
# File 'lib/prism/node.rb', line 4739

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) -> ClassVariableTargetNode



4749
4750
4751
# File 'lib/prism/node.rb', line 4749

def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name)
  ClassVariableTargetNode.new(source, node_id, location, flags, name)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }



4757
4758
4759
# File 'lib/prism/node.rb', line 4757

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

#each_child_nodeObject

def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator



4733
4734
4735
4736
# File 'lib/prism/node.rb', line 4733

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



4765
4766
4767
# File 'lib/prism/node.rb', line 4765

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



4770
4771
4772
# File 'lib/prism/node.rb', line 4770

def type
  :class_variable_target_node
end