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.



7004
7005
7006
7007
7008
7009
7010
# File 'lib/prism/node.rb', line 7004

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



7046
7047
7048
# File 'lib/prism/node.rb', line 7046

def name
  @name
end

Class Method Details

.typeObject

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



7059
7060
7061
# File 'lib/prism/node.rb', line 7059

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.



7065
7066
7067
7068
# File 'lib/prism/node.rb', line 7065

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



7013
7014
7015
# File 'lib/prism/node.rb', line 7013

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

#child_nodesObject Also known as: deconstruct

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



7018
7019
7020
# File 'lib/prism/node.rb', line 7018

def child_nodes
  []
end

#comment_targetsObject

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



7028
7029
7030
# File 'lib/prism/node.rb', line 7028

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



7023
7024
7025
# File 'lib/prism/node.rb', line 7023

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



7033
7034
7035
# File 'lib/prism/node.rb', line 7033

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 }



7041
7042
7043
# File 'lib/prism/node.rb', line 7041

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

#inspectObject

def inspect -> String



7049
7050
7051
# File 'lib/prism/node.rb', line 7049

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



7054
7055
7056
# File 'lib/prism/node.rb', line 7054

def type
  :global_variable_target_node
end