Class: YARP::ConstantPathAndWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantPathAndWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘&&=` operator for assignment to a constant path.
Parent::Child &&= value
^^^^^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#target ⇒ Object
readonly
attr_reader target: ConstantPathNode.
-
#value ⇒ Object
readonly
attr_reader value: 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) -> ConstantPathAndWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(target, operator_loc, value, location) ⇒ ConstantPathAndWriteNode
constructor
def initialize: (target: ConstantPathNode, operator_loc: Location, value: Node, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(target, operator_loc, value, location) ⇒ ConstantPathAndWriteNode
def initialize: (target: ConstantPathNode, operator_loc: Location, value: Node, location: Location) -> void
2790 2791 2792 2793 2794 2795 |
# File 'lib/yarp/node.rb', line 2790 def initialize(target, operator_loc, value, location) @target = target @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
2784 2785 2786 |
# File 'lib/yarp/node.rb', line 2784 def operator_loc @operator_loc end |
#target ⇒ Object (readonly)
attr_reader target: ConstantPathNode
2781 2782 2783 |
# File 'lib/yarp/node.rb', line 2781 def target @target end |
#value ⇒ Object (readonly)
attr_reader value: Node
2787 2788 2789 |
# File 'lib/yarp/node.rb', line 2787 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2798 2799 2800 |
# File 'lib/yarp/node.rb', line 2798 def accept(visitor) visitor.visit_constant_path_and_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2803 2804 2805 |
# File 'lib/yarp/node.rb', line 2803 def child_nodes [target, value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
2808 2809 2810 |
# File 'lib/yarp/node.rb', line 2808 def comment_targets [target, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantPathAndWriteNode
2813 2814 2815 2816 2817 2818 2819 2820 |
# File 'lib/yarp/node.rb', line 2813 def copy(**params) ConstantPathAndWriteNode.new( params.fetch(:target) { target }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
2826 2827 2828 |
# File 'lib/yarp/node.rb', line 2826 def deconstruct_keys(keys) { target: target, operator_loc: operator_loc, value: value, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
2835 2836 2837 2838 2839 2840 2841 2842 2843 |
# File 'lib/yarp/node.rb', line 2835 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── target:\n" inspector << inspector.child_node(target, "│ ") inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n" inspector << "└── value:\n" inspector << inspector.child_node(value, " ") inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
2831 2832 2833 |
# File 'lib/yarp/node.rb', line 2831 def operator operator_loc.slice end |