Class: YARP::ClassVariableTargetNode

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

Overview

Represents writing to a class variable in a context that doesn’t have an explicit value.

@@foo, @@bar = baz
^^^^^  ^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location) ⇒ ClassVariableTargetNode

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



1640
1641
1642
1643
# File 'lib/yarp/node.rb', line 1640

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



1637
1638
1639
# File 'lib/yarp/node.rb', line 1637

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1646
1647
1648
# File 'lib/yarp/node.rb', line 1646

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

#child_nodesObject Also known as: deconstruct

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



1651
1652
1653
# File 'lib/yarp/node.rb', line 1651

def child_nodes
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> ClassVariableTargetNode



1656
1657
1658
1659
1660
1661
# File 'lib/yarp/node.rb', line 1656

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



1667
1668
1669
# File 'lib/yarp/node.rb', line 1667

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