Class: Prism::GlobalVariableTargetNode

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

Overview

Represents writing to a global 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) ⇒ GlobalVariableTargetNode

Initialize a new GlobalVariableTargetNode node.



8547
8548
8549
8550
8551
8552
8553
# File 'lib/prism/node.rb', line 8547

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



8595
8596
8597
# File 'lib/prism/node.rb', line 8595

def name
  @name
end

Class Method Details

.typeObject

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



8608
8609
8610
# File 'lib/prism/node.rb', line 8608

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



8614
8615
8616
8617
# File 'lib/prism/node.rb', line 8614

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



8556
8557
8558
# File 'lib/prism/node.rb', line 8556

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



8561
8562
8563
# File 'lib/prism/node.rb', line 8561

def child_nodes
  []
end

#comment_targetsObject

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



8577
8578
8579
# File 'lib/prism/node.rb', line 8577

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



8572
8573
8574
# File 'lib/prism/node.rb', line 8572

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



8582
8583
8584
# File 'lib/prism/node.rb', line 8582

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

#deconstruct_keys(keys) ⇒ Object

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



8590
8591
8592
# File 'lib/prism/node.rb', line 8590

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



8566
8567
8568
8569
# File 'lib/prism/node.rb', line 8566

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



8598
8599
8600
# File 'lib/prism/node.rb', line 8598

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



8603
8604
8605
# File 'lib/prism/node.rb', line 8603

def type
  :global_variable_target_node
end