Class: YARP::InstanceVariableOperatorWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::InstanceVariableOperatorWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents assigning to an instance variable 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) -> InstanceVariableOperatorWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, value, operator, location) ⇒ InstanceVariableOperatorWriteNode
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) ⇒ InstanceVariableOperatorWriteNode
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, operator: Symbol, location: Location) -> void
5427 5428 5429 5430 5431 5432 5433 5434 |
# File 'lib/yarp/node.rb', line 5427 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
5412 5413 5414 |
# File 'lib/yarp/node.rb', line 5412 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
5415 5416 5417 |
# File 'lib/yarp/node.rb', line 5415 def name_loc @name_loc end |
#operator ⇒ Object (readonly)
attr_reader operator: Symbol
5424 5425 5426 |
# File 'lib/yarp/node.rb', line 5424 def operator @operator end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
5418 5419 5420 |
# File 'lib/yarp/node.rb', line 5418 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
5421 5422 5423 |
# File 'lib/yarp/node.rb', line 5421 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
5437 5438 5439 |
# File 'lib/yarp/node.rb', line 5437 def accept(visitor) visitor.visit_instance_variable_operator_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5442 5443 5444 |
# File 'lib/yarp/node.rb', line 5442 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
5447 5448 5449 |
# File 'lib/yarp/node.rb', line 5447 def comment_targets [name_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> InstanceVariableOperatorWriteNode
5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 |
# File 'lib/yarp/node.rb', line 5452 def copy(**params) InstanceVariableOperatorWriteNode.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
5467 5468 5469 |
# File 'lib/yarp/node.rb', line 5467 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
5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 |
# File 'lib/yarp/node.rb', line 5471 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 |