Class: YARP::ClassVariableReadNode

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

Overview

Represents referencing a class variable.

@@foo
^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location) ⇒ ClassVariableReadNode

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



2375
2376
2377
2378
# File 'lib/yarp/node.rb', line 2375

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



2372
2373
2374
# File 'lib/yarp/node.rb', line 2372

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2381
2382
2383
# File 'lib/yarp/node.rb', line 2381

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

#child_nodesObject Also known as: deconstruct

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



2386
2387
2388
# File 'lib/yarp/node.rb', line 2386

def child_nodes
  []
end

#comment_targetsObject

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



2391
2392
2393
# File 'lib/yarp/node.rb', line 2391

def comment_targets
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> ClassVariableReadNode



2396
2397
2398
2399
2400
2401
# File 'lib/yarp/node.rb', line 2396

def copy(**params)
  ClassVariableReadNode.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]



2407
2408
2409
# File 'lib/yarp/node.rb', line 2407

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

#inspect(inspector = NodeInspector.new) ⇒ Object



2411
2412
2413
2414
2415
# File 'lib/yarp/node.rb', line 2411

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