Class: YARP::ConstantPathNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantPathNode
- 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
-
#child ⇒ Object
readonly
attr_reader child: Node.
-
#delimiter_loc ⇒ Object
readonly
attr_reader delimiter_loc: Location.
-
#parent ⇒ Object
readonly
attr_reader parent: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantPathNode.
- #deconstruct_keys(keys) ⇒ Object
-
#delimiter ⇒ Object
def delimiter: () -> String.
-
#initialize(parent, child, delimiter_loc, location) ⇒ ConstantPathNode
constructor
def initialize: (parent: Node?, child: Node, delimiter_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
Constructor Details
#initialize(parent, child, delimiter_loc, location) ⇒ ConstantPathNode
def initialize: (parent: Node?, child: Node, delimiter_loc: Location, location: Location) -> void
2861 2862 2863 2864 2865 2866 |
# File 'lib/yarp/node.rb', line 2861 def initialize(parent, child, delimiter_loc, location) @parent = parent @child = child @delimiter_loc = delimiter_loc @location = location end |
Instance Attribute Details
#child ⇒ Object (readonly)
attr_reader child: Node
2855 2856 2857 |
# File 'lib/yarp/node.rb', line 2855 def child @child end |
#delimiter_loc ⇒ Object (readonly)
attr_reader delimiter_loc: Location
2858 2859 2860 |
# File 'lib/yarp/node.rb', line 2858 def delimiter_loc @delimiter_loc end |
#parent ⇒ Object (readonly)
attr_reader parent: Node?
2852 2853 2854 |
# File 'lib/yarp/node.rb', line 2852 def parent @parent end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2869 2870 2871 |
# File 'lib/yarp/node.rb', line 2869 def accept(visitor) visitor.visit_constant_path_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2874 2875 2876 |
# File 'lib/yarp/node.rb', line 2874 def child_nodes [parent, child] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
2879 2880 2881 |
# File 'lib/yarp/node.rb', line 2879 def comment_targets [*parent, child, delimiter_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantPathNode
2884 2885 2886 2887 2888 2889 2890 2891 |
# File 'lib/yarp/node.rb', line 2884 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
2897 2898 2899 |
# File 'lib/yarp/node.rb', line 2897 def deconstruct_keys(keys) { parent: parent, child: child, delimiter_loc: delimiter_loc, location: location } end |
#delimiter ⇒ Object
def delimiter: () -> String
2902 2903 2904 |
# File 'lib/yarp/node.rb', line 2902 def delimiter delimiter_loc.slice end |
#inspect(inspector = NodeInspector.new) ⇒ Object
2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 |
# File 'lib/yarp/node.rb', line 2906 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (parent = self.parent).nil? inspector << "├── parent: ∅\n" else inspector << "├── parent:\n" inspector << parent.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── child:\n" inspector << inspector.child_node(child, "│ ") inspector << "└── delimiter_loc: #{inspector.location(delimiter_loc)}\n" inspector.to_str end |