Class: YARP::ConstantOperatorWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantOperatorWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents assigning to a constant using an operator that isn’t ‘=`.
Target += value
^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
-
#name_loc ⇒ Object
readonly
attr_reader name_loc: Location.
-
#operator ⇒ Object
readonly
attr_reader operator: Symbol.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#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) -> ConstantOperatorWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, value, operator, location) ⇒ ConstantOperatorWriteNode
constructor
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, operator: Symbol, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
Constructor Details
#initialize(name, name_loc, operator_loc, value, operator, location) ⇒ ConstantOperatorWriteNode
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, operator: Symbol, location: Location) -> void
2643 2644 2645 2646 2647 2648 2649 2650 |
# File 'lib/yarp/node.rb', line 2643 def initialize(name, name_loc, operator_loc, value, operator, location) @name = name @name_loc = name_loc @operator_loc = operator_loc @value = value @operator = operator @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol
2628 2629 2630 |
# File 'lib/yarp/node.rb', line 2628 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
2631 2632 2633 |
# File 'lib/yarp/node.rb', line 2631 def name_loc @name_loc end |
#operator ⇒ Object (readonly)
attr_reader operator: Symbol
2640 2641 2642 |
# File 'lib/yarp/node.rb', line 2640 def operator @operator end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
2634 2635 2636 |
# File 'lib/yarp/node.rb', line 2634 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
2637 2638 2639 |
# File 'lib/yarp/node.rb', line 2637 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2653 2654 2655 |
# File 'lib/yarp/node.rb', line 2653 def accept(visitor) visitor.visit_constant_operator_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2658 2659 2660 |
# File 'lib/yarp/node.rb', line 2658 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
2663 2664 2665 |
# File 'lib/yarp/node.rb', line 2663 def comment_targets [name_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantOperatorWriteNode
2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 |
# File 'lib/yarp/node.rb', line 2668 def copy(**params) ConstantOperatorWriteNode.new( params.fetch(:name) { name }, params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:operator) { operator }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
2683 2684 2685 |
# File 'lib/yarp/node.rb', line 2683 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, value: value, operator: operator, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 |
# File 'lib/yarp/node.rb', line 2687 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── name: #{name.inspect}\n" inspector << "├── name_loc: #{inspector.location(name_loc)}\n" inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n" inspector << "├── value:\n" inspector << inspector.child_node(value, "│ ") inspector << "└── operator: #{operator.inspect}\n" inspector.to_str end |