Class: YARP::GlobalVariableReadNode

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

Overview

Represents referencing a global variable.

$foo
^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location) ⇒ GlobalVariableReadNode

def initialize: (name: Symbol, location: Location) -> void



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

def initialize(name, location)
  @name = name
  @location = location
end

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



4740
4741
4742
# File 'lib/yarp/node.rb', line 4740

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



4754
4755
4756
# File 'lib/yarp/node.rb', line 4754

def child_nodes
  []
end

#comment_targetsObject

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



4759
4760
4761
# File 'lib/yarp/node.rb', line 4759

def comment_targets
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> GlobalVariableReadNode



4764
4765
4766
4767
4768
4769
# File 'lib/yarp/node.rb', line 4764

def copy(**params)
  GlobalVariableReadNode.new(
    params.fetch(:name) { name },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



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

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

#inspect(inspector = NodeInspector.new) ⇒ Object



4779
4780
4781
4782
4783
# File 'lib/yarp/node.rb', line 4779

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "└── name: #{name.inspect}\n"
  inspector.to_str
end