Class: YARP::MultiWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::MultiWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a write to a multi-target expression.
a, b, c = 1, 2, 3
^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#lparen_loc ⇒ Object
readonly
attr_reader lparen_loc: Location?.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#rparen_loc ⇒ Object
readonly
attr_reader rparen_loc: Location?.
-
#targets ⇒ Object
readonly
attr_reader targets: Array.
-
#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) -> MultiWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(targets, lparen_loc, rparen_loc, operator_loc, value, location) ⇒ MultiWriteNode
constructor
def initialize: (targets: Array, lparen_loc: Location?, rparen_loc: Location?, operator_loc: Location, value: Node, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#lparen ⇒ Object
def lparen: () -> String?.
-
#operator ⇒ Object
def operator: () -> String.
-
#rparen ⇒ Object
def rparen: () -> String?.
Constructor Details
#initialize(targets, lparen_loc, rparen_loc, operator_loc, value, location) ⇒ MultiWriteNode
def initialize: (targets: Array, lparen_loc: Location?, rparen_loc: Location?, operator_loc: Location, value: Node, location: Location) -> void
7276 7277 7278 7279 7280 7281 7282 7283 |
# File 'lib/yarp/node.rb', line 7276 def initialize(targets, lparen_loc, rparen_loc, operator_loc, value, location) @targets = targets @lparen_loc = lparen_loc @rparen_loc = rparen_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#lparen_loc ⇒ Object (readonly)
attr_reader lparen_loc: Location?
7264 7265 7266 |
# File 'lib/yarp/node.rb', line 7264 def lparen_loc @lparen_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
7270 7271 7272 |
# File 'lib/yarp/node.rb', line 7270 def operator_loc @operator_loc end |
#rparen_loc ⇒ Object (readonly)
attr_reader rparen_loc: Location?
7267 7268 7269 |
# File 'lib/yarp/node.rb', line 7267 def rparen_loc @rparen_loc end |
#targets ⇒ Object (readonly)
attr_reader targets: Array
7261 7262 7263 |
# File 'lib/yarp/node.rb', line 7261 def targets @targets end |
#value ⇒ Object (readonly)
attr_reader value: Node
7273 7274 7275 |
# File 'lib/yarp/node.rb', line 7273 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
7286 7287 7288 |
# File 'lib/yarp/node.rb', line 7286 def accept(visitor) visitor.visit_multi_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
7291 7292 7293 |
# File 'lib/yarp/node.rb', line 7291 def child_nodes [*targets, value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
7296 7297 7298 |
# File 'lib/yarp/node.rb', line 7296 def comment_targets [*targets, *lparen_loc, *rparen_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> MultiWriteNode
7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 |
# File 'lib/yarp/node.rb', line 7301 def copy(**params) MultiWriteNode.new( params.fetch(:targets) { targets }, params.fetch(:lparen_loc) { lparen_loc }, params.fetch(:rparen_loc) { rparen_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
7316 7317 7318 |
# File 'lib/yarp/node.rb', line 7316 def deconstruct_keys(keys) { targets: targets, lparen_loc: lparen_loc, rparen_loc: rparen_loc, operator_loc: operator_loc, value: value, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 |
# File 'lib/yarp/node.rb', line 7335 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── targets: #{inspector.list("#{inspector.prefix}│ ", targets)}" inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n" inspector << "├── rparen_loc: #{inspector.location(rparen_loc)}\n" inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n" inspector << "└── value:\n" inspector << inspector.child_node(value, " ") inspector.to_str end |
#lparen ⇒ Object
def lparen: () -> String?
7321 7322 7323 |
# File 'lib/yarp/node.rb', line 7321 def lparen lparen_loc&.slice end |
#operator ⇒ Object
def operator: () -> String
7331 7332 7333 |
# File 'lib/yarp/node.rb', line 7331 def operator operator_loc.slice end |
#rparen ⇒ Object
def rparen: () -> String?
7326 7327 7328 |
# File 'lib/yarp/node.rb', line 7326 def rparen rparen_loc&.slice end |