Class: YARP::LambdaNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::LambdaNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents using a lambda literal (not the lambda method call).
->(value) { value * 2 }
^^^^^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#locals ⇒ Object
readonly
attr_reader locals: Array.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
-
#parameters ⇒ Object
readonly
attr_reader parameters: Node?.
-
#statements ⇒ Object
readonly
attr_reader statements: 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(locals, opening_loc, parameters, statements, location) ⇒ LambdaNode
constructor
def initialize: (locals: Array, opening_loc: Location, parameters: Node?, statements: Node?, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String.
Constructor Details
#initialize(locals, opening_loc, parameters, statements, location) ⇒ LambdaNode
def initialize: (locals: Array, opening_loc: Location, parameters: Node?, statements: Node?, location: Location) -> void
3768 3769 3770 3771 3772 3773 3774 |
# File 'lib/yarp/node.rb', line 3768 def initialize(locals, opening_loc, parameters, statements, location) @locals = locals @opening_loc = opening_loc @parameters = parameters @statements = statements @location = location end |
Instance Attribute Details
#locals ⇒ Object (readonly)
attr_reader locals: Array
3756 3757 3758 |
# File 'lib/yarp/node.rb', line 3756 def locals @locals end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
3759 3760 3761 |
# File 'lib/yarp/node.rb', line 3759 def opening_loc @opening_loc end |
#parameters ⇒ Object (readonly)
attr_reader parameters: Node?
3762 3763 3764 |
# File 'lib/yarp/node.rb', line 3762 def parameters @parameters end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
3765 3766 3767 |
# File 'lib/yarp/node.rb', line 3765 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
3777 3778 3779 |
# File 'lib/yarp/node.rb', line 3777 def accept(visitor) visitor.visit_lambda_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3782 3783 3784 |
# File 'lib/yarp/node.rb', line 3782 def child_nodes [parameters, statements] end |
#deconstruct_keys(keys) ⇒ Object
3790 3791 3792 |
# File 'lib/yarp/node.rb', line 3790 def deconstruct_keys(keys) { locals: locals, opening_loc: opening_loc, parameters: parameters, statements: statements, location: location } end |
#opening ⇒ Object
def opening: () -> String
3795 3796 3797 |
# File 'lib/yarp/node.rb', line 3795 def opening opening_loc.slice end |