Class: YARP::ConstantAndWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantAndWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘&&=` operator for assignment to a constant.
Target &&= value
^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
-
#name_loc ⇒ Object
readonly
attr_reader name_loc: Location.
-
#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) -> ConstantAndWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, value, location) ⇒ ConstantAndWriteNode
constructor
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name, name_loc, operator_loc, value, location) ⇒ ConstantAndWriteNode
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void
2564 2565 2566 2567 2568 2569 2570 |
# File 'lib/yarp/node.rb', line 2564 def initialize(name, name_loc, operator_loc, value, location) @name = name @name_loc = name_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol
2552 2553 2554 |
# File 'lib/yarp/node.rb', line 2552 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
2555 2556 2557 |
# File 'lib/yarp/node.rb', line 2555 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
2558 2559 2560 |
# File 'lib/yarp/node.rb', line 2558 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
2561 2562 2563 |
# File 'lib/yarp/node.rb', line 2561 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2573 2574 2575 |
# File 'lib/yarp/node.rb', line 2573 def accept(visitor) visitor.visit_constant_and_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2578 2579 2580 |
# File 'lib/yarp/node.rb', line 2578 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
2583 2584 2585 |
# File 'lib/yarp/node.rb', line 2583 def comment_targets [name_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantAndWriteNode
2588 2589 2590 2591 2592 2593 2594 2595 2596 |
# File 'lib/yarp/node.rb', line 2588 def copy(**params) ConstantAndWriteNode.new( params.fetch(:name) { name }, params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
2602 2603 2604 |
# File 'lib/yarp/node.rb', line 2602 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, value: value, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
2611 2612 2613 2614 2615 2616 2617 2618 2619 |
# File 'lib/yarp/node.rb', line 2611 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.to_str end |
#operator ⇒ Object
def operator: () -> String
2607 2608 2609 |
# File 'lib/yarp/node.rb', line 2607 def operator operator_loc.slice end |