class Prism::LambdaNode
Represents using a lambda literal (not the lambda method call).
->(value) { value * 2 }
^^^^^^^^^^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 19526 def initialize(source, node_id, location, flags, locals, operator_loc, opening_loc, closing_loc, parameters, body) @source = source @node_id = node_id @location = location @flags = flags @locals = locals @operator_loc = operator_loc @opening_loc = opening_loc @closing_loc = closing_loc @parameters = parameters @body = body end
Initialize a new LambdaNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 19722 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 19636 def locals @locals end
Returns the locals attribute.
Source
# File lib/prism/node.rb, line 19712 def parameters @parameters end
Returns the parameters attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 19691 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by closing_loc.
Source
# File lib/prism/node.rb, line 19669 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by opening_loc.
Source
# File lib/prism/node.rb, line 19647 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by operator_loc.
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 19553 def accept(visitor) visitor.visit_lambda_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 19560 def child_nodes [parameters, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 19588 def comment_targets [operator_loc, opening_loc, closing_loc, *parameters, *body] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 19578 def compact_child_nodes compact = [] #: Array[Prism::node] if (parameters = self.parameters); compact << parameters; end if (body = self.body); compact << body; end compact end
Source
# File lib/prism/node.rb, line 19598 def copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, operator_loc: self.operator_loc, opening_loc: self.opening_loc, closing_loc: self.closing_loc, parameters: self.parameters, body: self.body) LambdaNode.new(source, node_id, location, flags, locals, operator_loc, opening_loc, closing_loc, parameters, body) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 19568 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (parameters = self.parameters); yield parameters; end if (body = self.body); yield body; end end
See Node.each_child_node.
Repository
Methods related to Relocation.
Public Instance Methods
Source
# File lib/prism/node.rb, line 19702 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end
Save the closing_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 19680 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end
Save the opening_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 19658 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end
Save the operator_loc location using the given saved source so that it can be retrieved later.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 19754 def closing closing_loc.slice end
Slice the location of closing_loc from the source.
Source
# File lib/prism/node.rb, line 19744 def opening opening_loc.slice end
Slice the location of opening_loc from the source.
Source
# File lib/prism/node.rb, line 19734 def operator operator_loc.slice end
Slice the location of operator_loc from the source.