class YARP::LambdaNode
Represents using a lambda literal (not the lambda method call).
->(value) { value * 2 } ^^^^^^^^^^^^^^^^^^^^^^^
Attributes
attr_reader body: Node
?
attr_reader closing_loc
: Location
attr_reader locals: Array
attr_reader opening_loc
: Location
attr_reader operator_loc
: Location
attr_reader parameters: BlockParametersNode
?
Public Class Methods
def initialize: (locals: Array, operator_loc
: Location
, opening_loc
: Location
, closing_loc
: Location
, parameters: BlockParametersNode
?, body: Node
?, location: Location
) -> void
# File yarp/node.rb, line 6599 def initialize(locals, operator_loc, opening_loc, closing_loc, parameters, body, location) @locals = locals @operator_loc = operator_loc @opening_loc = opening_loc @closing_loc = closing_loc @parameters = parameters @body = body @location = location end
Public Instance Methods
def accept: (visitor: Visitor
) -> void
# File yarp/node.rb, line 6610 def accept(visitor) visitor.visit_lambda_node(self) end
def child_nodes
: () -> Array[nil | Node]
# File yarp/node.rb, line 6615 def child_nodes [parameters, body] end
def closing: () -> String
# File yarp/node.rb, line 6656 def closing closing_loc.slice end
def comment_targets
: () -> Array[Node | Location]
# File yarp/node.rb, line 6620 def comment_targets [operator_loc, opening_loc, closing_loc, *parameters, *body] end
def copy: (**params) -> LambdaNode
# File yarp/node.rb, line 6625 def copy(**params) LambdaNode.new( params.fetch(:locals) { locals }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:parameters) { parameters }, params.fetch(:body) { body }, params.fetch(:location) { location }, ) end
def deconstruct_keys
: (keys: Array) -> Hash[Symbol, nil | Node
| Array | String | Token
| Array | Location]
# File yarp/node.rb, line 6641 def deconstruct_keys(keys) { locals: locals, operator_loc: operator_loc, opening_loc: opening_loc, closing_loc: closing_loc, parameters: parameters, body: body, location: location } end
# File yarp/node.rb, line 6660 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── locals: #{locals.inspect}\n" inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n" inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n" if (parameters = self.parameters).nil? inspector << "├── parameters: ∅\n" else inspector << "├── parameters:\n" inspector << parameters.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end if (body = self.body).nil? inspector << "└── body: ∅\n" else inspector << "└── body:\n" inspector << body.inspect(inspector.child_inspector(" ")).delete_prefix(inspector.prefix) end inspector.to_str end
def opening: () -> String
# File yarp/node.rb, line 6651 def opening opening_loc.slice end
def operator: () -> String
# File yarp/node.rb, line 6646 def operator operator_loc.slice end