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



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

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



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

def child
  @child
end

#delimiter_locObject (readonly)

attr_reader delimiter_loc: Location



1589
1590
1591
# File 'lib/yarp/node.rb', line 1589

def delimiter_loc
  @delimiter_loc
end

#parentObject (readonly)

attr_reader parent: Node?



1583
1584
1585
# File 'lib/yarp/node.rb', line 1583

def parent
  @parent
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



1606
1607
1608
# File 'lib/yarp/node.rb', line 1606

def child_nodes
  [parent, child]
end

#deconstruct_keys(keys) ⇒ Object

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



1614
1615
1616
# File 'lib/yarp/node.rb', line 1614

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

#delimiterObject

def delimiter: () -> String



1619
1620
1621
# File 'lib/yarp/node.rb', line 1619

def delimiter
  delimiter_loc.slice
end