Class: YARP::InstanceVariableOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::InstanceVariableOrWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘||=` operator for assignment to an instance variable.
@target ||= value
^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#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].
-
#copy(**params) ⇒ Object
def copy: (**params) -> InstanceVariableOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, value, location) ⇒ InstanceVariableOrWriteNode
constructor
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name, name_loc, operator_loc, value, location) ⇒ InstanceVariableOrWriteNode
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void
4030 4031 4032 4033 4034 4035 4036 |
# File 'lib/yarp/node.rb', line 4030 def initialize(name, name_loc, operator_loc, value, location) @name = name @name_loc = name_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol
4018 4019 4020 |
# File 'lib/yarp/node.rb', line 4018 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
4021 4022 4023 |
# File 'lib/yarp/node.rb', line 4021 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
4024 4025 4026 |
# File 'lib/yarp/node.rb', line 4024 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
4027 4028 4029 |
# File 'lib/yarp/node.rb', line 4027 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4039 4040 4041 |
# File 'lib/yarp/node.rb', line 4039 def accept(visitor) visitor.visit_instance_variable_or_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4044 4045 4046 |
# File 'lib/yarp/node.rb', line 4044 def child_nodes [value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> InstanceVariableOrWriteNode
4049 4050 4051 4052 4053 4054 4055 4056 4057 |
# File 'lib/yarp/node.rb', line 4049 def copy(**params) InstanceVariableOrWriteNode.new( params.fetch(:name) { name }, params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
4063 4064 4065 |
# File 'lib/yarp/node.rb', line 4063 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, value: value, location: location } end |
#operator ⇒ Object
def operator: () -> String
4068 4069 4070 |
# File 'lib/yarp/node.rb', line 4068 def operator operator_loc.slice end |