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
4453 4454 4455 4456 4457 4458 4459 |
# File 'lib/yarp/node.rb', line 4453 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
4441 4442 4443 |
# File 'lib/yarp/node.rb', line 4441 def constant_id @constant_id end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
4444 4445 4446 |
# File 'lib/yarp/node.rb', line 4444 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
4447 4448 4449 |
# File 'lib/yarp/node.rb', line 4447 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
4450 4451 4452 |
# File 'lib/yarp/node.rb', line 4450 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4462 4463 4464 |
# File 'lib/yarp/node.rb', line 4462 def accept(visitor) visitor.visit_optional_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4468 4469 4470 |
# File 'lib/yarp/node.rb', line 4468 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
4476 4477 4478 |
# File 'lib/yarp/node.rb', line 4476 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
4481 4482 4483 |
# File 'lib/yarp/node.rb', line 4481 def name name_loc.slice end |
#operator ⇒ Object
def operator: () -> String
4486 4487 4488 |
# File 'lib/yarp/node.rb', line 4486 def operator operator_loc.slice end |