Class: YARP::OptionalParameterNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::OptionalParameterNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents an optional parameter to a method, block, or lambda definition.
def a(b = 1)
^^^^^
end
Instance Attribute Summary collapse
-
#constant_id ⇒ Object
readonly
attr_reader constant_id: 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].
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(constant_id, name_loc, operator_loc, value, location) ⇒ OptionalParameterNode
constructor
def initialize: (constant_id: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void.
-
#name ⇒ Object
def name: () -> String.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(constant_id, name_loc, operator_loc, value, location) ⇒ OptionalParameterNode
def initialize: (constant_id: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void
4476 4477 4478 4479 4480 4481 4482 |
# File 'lib/yarp/node.rb', line 4476 def initialize(constant_id, name_loc, operator_loc, value, location) @constant_id = constant_id @name_loc = name_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#constant_id ⇒ Object (readonly)
attr_reader constant_id: Symbol
4464 4465 4466 |
# File 'lib/yarp/node.rb', line 4464 def constant_id @constant_id end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
4467 4468 4469 |
# File 'lib/yarp/node.rb', line 4467 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
4470 4471 4472 |
# File 'lib/yarp/node.rb', line 4470 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
4473 4474 4475 |
# File 'lib/yarp/node.rb', line 4473 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4485 4486 4487 |
# File 'lib/yarp/node.rb', line 4485 def accept(visitor) visitor.visit_optional_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4490 4491 4492 |
# File 'lib/yarp/node.rb', line 4490 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
4498 4499 4500 |
# File 'lib/yarp/node.rb', line 4498 def deconstruct_keys(keys) { constant_id: constant_id, name_loc: name_loc, operator_loc: operator_loc, value: value, location: location } end |
#name ⇒ Object
def name: () -> String
4503 4504 4505 |
# File 'lib/yarp/node.rb', line 4503 def name name_loc.slice end |
#operator ⇒ Object
def operator: () -> String
4508 4509 4510 |
# File 'lib/yarp/node.rb', line 4508 def operator operator_loc.slice end |