Class: YARP::ConstantPathNode

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

Overview

Represents accessing a constant through a path of ‘::` operators.

Foo::Bar
^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, child, delimiter_loc, location) ⇒ ConstantPathNode

def initialize: (parent: Node?, child: Node, delimiter_loc: Location, location: Location) -> void



1573
1574
1575
1576
1577
1578
# File 'lib/yarp/node.rb', line 1573

def initialize(parent, child, delimiter_loc, location)
  @parent = parent
  @child = child
  @delimiter_loc = delimiter_loc
  @location = location
end

Instance Attribute Details

#childObject (readonly)

attr_reader child: Node



1567
1568
1569
# File 'lib/yarp/node.rb', line 1567

def child
  @child
end

#delimiter_locObject (readonly)

attr_reader delimiter_loc: Location



1570
1571
1572
# File 'lib/yarp/node.rb', line 1570

def delimiter_loc
  @delimiter_loc
end

#parentObject (readonly)

attr_reader parent: Node?



1564
1565
1566
# File 'lib/yarp/node.rb', line 1564

def parent
  @parent
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1581
1582
1583
# File 'lib/yarp/node.rb', line 1581

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

#child_nodesObject Also known as: deconstruct

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



1586
1587
1588
# File 'lib/yarp/node.rb', line 1586

def child_nodes
  [parent, child]
end

#deconstruct_keys(keys) ⇒ Object

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



1594
1595
1596
# File 'lib/yarp/node.rb', line 1594

def deconstruct_keys(keys)
  { parent: parent, child: child, delimiter_loc: delimiter_loc, location: location }
end

#delimiterObject

def delimiter: () -> String



1599
1600
1601
# File 'lib/yarp/node.rb', line 1599

def delimiter
  delimiter_loc.slice
end