Class: YARP::ConstantOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantOrWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘||=` operator for assignment to a constant.
Target ||= value
^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#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) -> ConstantOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name_loc, operator_loc, value, location) ⇒ ConstantOrWriteNode
constructor
def initialize: (name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void.
-
#name ⇒ Object
def name: () -> String.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name_loc, operator_loc, value, location) ⇒ ConstantOrWriteNode
def initialize: (name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void
1870 1871 1872 1873 1874 1875 |
# File 'lib/yarp/node.rb', line 1870 def initialize(name_loc, operator_loc, value, location) @name_loc = name_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
1861 1862 1863 |
# File 'lib/yarp/node.rb', line 1861 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
1864 1865 1866 |
# File 'lib/yarp/node.rb', line 1864 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
1867 1868 1869 |
# File 'lib/yarp/node.rb', line 1867 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1878 1879 1880 |
# File 'lib/yarp/node.rb', line 1878 def accept(visitor) visitor.visit_constant_or_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1883 1884 1885 |
# File 'lib/yarp/node.rb', line 1883 def child_nodes [value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantOrWriteNode
1888 1889 1890 1891 1892 1893 1894 1895 |
# File 'lib/yarp/node.rb', line 1888 def copy(**params) ConstantOrWriteNode.new( 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
1901 1902 1903 |
# File 'lib/yarp/node.rb', line 1901 def deconstruct_keys(keys) { name_loc: name_loc, operator_loc: operator_loc, value: value, location: location } end |
#name ⇒ Object
def name: () -> String
1906 1907 1908 |
# File 'lib/yarp/node.rb', line 1906 def name name_loc.slice end |
#operator ⇒ Object
def operator: () -> String
1911 1912 1913 |
# File 'lib/yarp/node.rb', line 1911 def operator operator_loc.slice end |