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
3730 3731 3732 3733 3734 3735 3736 |
# File 'lib/yarp/node.rb', line 3730 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
3718 3719 3720 |
# File 'lib/yarp/node.rb', line 3718 def locals @locals end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
3721 3722 3723 |
# File 'lib/yarp/node.rb', line 3721 def opening_loc @opening_loc end |
#parameters ⇒ Object (readonly)
attr_reader parameters: Node?
3724 3725 3726 |
# File 'lib/yarp/node.rb', line 3724 def parameters @parameters end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
3727 3728 3729 |
# File 'lib/yarp/node.rb', line 3727 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
3739 3740 3741 |
# File 'lib/yarp/node.rb', line 3739 def accept(visitor) visitor.visit_lambda_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3745 3746 3747 |
# File 'lib/yarp/node.rb', line 3745 def child_nodes [parameters, statements] end |
#deconstruct_keys(keys) ⇒ Object
3753 3754 3755 |
# File 'lib/yarp/node.rb', line 3753 def deconstruct_keys(keys) { locals: locals, opening_loc: opening_loc, parameters: parameters, statements: statements, location: location } end |
#opening ⇒ Object
def opening: () -> String
3758 3759 3760 |
# File 'lib/yarp/node.rb', line 3758 def opening opening_loc.slice end |