Class: YARP::LocalVariableOperatorWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::LocalVariableOperatorWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents assigning to a local variable using an operator that isn’t ‘=`.
target += value
^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
attr_reader depth: Integer.
-
#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) -> LocalVariableOperatorWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name_loc, operator_loc, value, name, operator, depth, location) ⇒ LocalVariableOperatorWriteNode
constructor
def initialize: (name_loc: Location, operator_loc: Location, value: Node, name: Symbol, operator: Symbol, depth: Integer, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
Constructor Details
#initialize(name_loc, operator_loc, value, name, operator, depth, location) ⇒ LocalVariableOperatorWriteNode
def initialize: (name_loc: Location, operator_loc: Location, value: Node, name: Symbol, operator: Symbol, depth: Integer, location: Location) -> void
6556 6557 6558 6559 6560 6561 6562 6563 6564 |
# File 'lib/yarp/node.rb', line 6556 def initialize(name_loc, operator_loc, value, name, operator, depth, location) @name_loc = name_loc @operator_loc = operator_loc @value = value @name = name @operator = operator @depth = depth @location = location end |
Instance Attribute Details
#depth ⇒ Object (readonly)
attr_reader depth: Integer
6553 6554 6555 |
# File 'lib/yarp/node.rb', line 6553 def depth @depth end |
#name ⇒ Object (readonly)
attr_reader name: Symbol
6547 6548 6549 |
# File 'lib/yarp/node.rb', line 6547 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
6538 6539 6540 |
# File 'lib/yarp/node.rb', line 6538 def name_loc @name_loc end |
#operator ⇒ Object (readonly)
attr_reader operator: Symbol
6550 6551 6552 |
# File 'lib/yarp/node.rb', line 6550 def operator @operator end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
6541 6542 6543 |
# File 'lib/yarp/node.rb', line 6541 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
6544 6545 6546 |
# File 'lib/yarp/node.rb', line 6544 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6567 6568 6569 |
# File 'lib/yarp/node.rb', line 6567 def accept(visitor) visitor.visit_local_variable_operator_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6572 6573 6574 |
# File 'lib/yarp/node.rb', line 6572 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6577 6578 6579 |
# File 'lib/yarp/node.rb', line 6577 def comment_targets [name_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> LocalVariableOperatorWriteNode
6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 |
# File 'lib/yarp/node.rb', line 6582 def copy(**params) LocalVariableOperatorWriteNode.new( params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:name) { name }, params.fetch(:operator) { operator }, params.fetch(:depth) { depth }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
6598 6599 6600 |
# File 'lib/yarp/node.rb', line 6598 def deconstruct_keys(keys) { name_loc: name_loc, operator_loc: operator_loc, value: value, name: name, operator: operator, depth: depth, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 |
# File 'lib/yarp/node.rb', line 6602 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) 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 << "├── name: #{name.inspect}\n" inspector << "├── operator: #{operator.inspect}\n" inspector << "└── depth: #{depth.inspect}\n" inspector.to_str end |