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



1987
1988
1989
1990
1991
1992
# File 'lib/yarp/node.rb', line 1987

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



1981
1982
1983
# File 'lib/yarp/node.rb', line 1981

def child
  @child
end

#delimiter_locObject (readonly)

attr_reader delimiter_loc: Location



1984
1985
1986
# File 'lib/yarp/node.rb', line 1984

def delimiter_loc
  @delimiter_loc
end

#parentObject (readonly)

attr_reader parent: Node?



1978
1979
1980
# File 'lib/yarp/node.rb', line 1978

def parent
  @parent
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1995
1996
1997
# File 'lib/yarp/node.rb', line 1995

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

#child_nodesObject Also known as: deconstruct

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



2000
2001
2002
# File 'lib/yarp/node.rb', line 2000

def child_nodes
  [parent, child]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ConstantPathNode



2005
2006
2007
2008
2009
2010
2011
2012
# File 'lib/yarp/node.rb', line 2005

def copy(**params)
  ConstantPathNode.new(
    params.fetch(:parent) { parent },
    params.fetch(:child) { child },
    params.fetch(:delimiter_loc) { delimiter_loc },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



2018
2019
2020
# File 'lib/yarp/node.rb', line 2018

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

#delimiterObject

def delimiter: () -> String



2023
2024
2025
# File 'lib/yarp/node.rb', line 2023

def delimiter
  delimiter_loc.slice
end