Class: YARP::LocalVariableAndWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::LocalVariableAndWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘&&=` operator for assignment to a local variable.
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_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) -> LocalVariableAndWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name_loc, operator_loc, value, name, depth, location) ⇒ LocalVariableAndWriteNode
constructor
def initialize: (name_loc: Location, operator_loc: Location, value: Node, name: Symbol, depth: Integer, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name_loc, operator_loc, value, name, depth, location) ⇒ LocalVariableAndWriteNode
def initialize: (name_loc: Location, operator_loc: Location, value: Node, name: Symbol, depth: Integer, location: Location) -> void
6471 6472 6473 6474 6475 6476 6477 6478 |
# File 'lib/yarp/node.rb', line 6471 def initialize(name_loc, operator_loc, value, name, depth, location) @name_loc = name_loc @operator_loc = operator_loc @value = value @name = name @depth = depth @location = location end |
Instance Attribute Details
#depth ⇒ Object (readonly)
attr_reader depth: Integer
6468 6469 6470 |
# File 'lib/yarp/node.rb', line 6468 def depth @depth end |
#name ⇒ Object (readonly)
attr_reader name: Symbol
6465 6466 6467 |
# File 'lib/yarp/node.rb', line 6465 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
6456 6457 6458 |
# File 'lib/yarp/node.rb', line 6456 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
6459 6460 6461 |
# File 'lib/yarp/node.rb', line 6459 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
6462 6463 6464 |
# File 'lib/yarp/node.rb', line 6462 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6481 6482 6483 |
# File 'lib/yarp/node.rb', line 6481 def accept(visitor) visitor.visit_local_variable_and_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6486 6487 6488 |
# File 'lib/yarp/node.rb', line 6486 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6491 6492 6493 |
# File 'lib/yarp/node.rb', line 6491 def comment_targets [name_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> LocalVariableAndWriteNode
6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 |
# File 'lib/yarp/node.rb', line 6496 def copy(**params) LocalVariableAndWriteNode.new( params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:name) { name }, params.fetch(:depth) { depth }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
6511 6512 6513 |
# File 'lib/yarp/node.rb', line 6511 def deconstruct_keys(keys) { name_loc: name_loc, operator_loc: operator_loc, value: value, name: name, depth: depth, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 |
# File 'lib/yarp/node.rb', line 6520 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 << "└── depth: #{depth.inspect}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
6516 6517 6518 |
# File 'lib/yarp/node.rb', line 6516 def operator operator_loc.slice end |