Class: YARP::GlobalVariableOperatorWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::GlobalVariableOperatorWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents assigning to a global 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) -> GlobalVariableOperatorWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, value, operator, location) ⇒ GlobalVariableOperatorWriteNode
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) ⇒ GlobalVariableOperatorWriteNode
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, operator: Symbol, location: Location) -> void
4602 4603 4604 4605 4606 4607 4608 4609 |
# File 'lib/yarp/node.rb', line 4602 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
4587 4588 4589 |
# File 'lib/yarp/node.rb', line 4587 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
4590 4591 4592 |
# File 'lib/yarp/node.rb', line 4590 def name_loc @name_loc end |
#operator ⇒ Object (readonly)
attr_reader operator: Symbol
4599 4600 4601 |
# File 'lib/yarp/node.rb', line 4599 def operator @operator end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
4593 4594 4595 |
# File 'lib/yarp/node.rb', line 4593 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
4596 4597 4598 |
# File 'lib/yarp/node.rb', line 4596 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4612 4613 4614 |
# File 'lib/yarp/node.rb', line 4612 def accept(visitor) visitor.visit_global_variable_operator_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4617 4618 4619 |
# File 'lib/yarp/node.rb', line 4617 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
4622 4623 4624 |
# File 'lib/yarp/node.rb', line 4622 def comment_targets [name_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> GlobalVariableOperatorWriteNode
4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 |
# File 'lib/yarp/node.rb', line 4627 def copy(**params) GlobalVariableOperatorWriteNode.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
4642 4643 4644 |
# File 'lib/yarp/node.rb', line 4642 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
4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 |
# File 'lib/yarp/node.rb', line 4646 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 |