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.



8036
8037
8038
8039
8040
8041
8042
# File 'lib/prism/node.rb', line 8036

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



8078
8079
8080
# File 'lib/prism/node.rb', line 8078

def name
  @name
end

Class Method Details

.typeObject

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



8091
8092
8093
# File 'lib/prism/node.rb', line 8091

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.



8097
8098
8099
8100
# File 'lib/prism/node.rb', line 8097

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



8045
8046
8047
# File 'lib/prism/node.rb', line 8045

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



8050
8051
8052
# File 'lib/prism/node.rb', line 8050

def child_nodes
  []
end

#comment_targetsObject

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



8060
8061
8062
# File 'lib/prism/node.rb', line 8060

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



8055
8056
8057
# File 'lib/prism/node.rb', line 8055

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



8065
8066
8067
# File 'lib/prism/node.rb', line 8065

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 }



8073
8074
8075
# File 'lib/prism/node.rb', line 8073

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

#inspectObject

def inspect -> String



8081
8082
8083
# File 'lib/prism/node.rb', line 8081

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



8086
8087
8088
# File 'lib/prism/node.rb', line 8086

def type
  :global_variable_target_node
end