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 15703 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 15862 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 15792 def locals @locals end
Returns the locals attribute.
Source
# File lib/prism/node.rb, line 15854 def parameters @parameters end
Returns the parameters attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 15837 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 15819 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 15801 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
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 15728 def accept(visitor) visitor.visit_lambda_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 15733 def child_nodes [parameters, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 15754 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 15746 def compact_child_nodes compact = [] #: Array[Prism::node] compact << parameters if parameters compact << body if body compact end
Source
# File lib/prism/node.rb, line 15762 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 15738 def each_child_node return to_enum(:each_child_node) unless block_given? yield parameters if parameters yield body if body end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 15846 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 15828 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 15810 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 15888 def closing closing_loc.slice end
Slice the location of closing_loc from the source.
Source
# File lib/prism/node.rb, line 15880 def opening opening_loc.slice end
Slice the location of opening_loc from the source.
Source
# File lib/prism/node.rb, line 15872 def operator operator_loc.slice end
Slice the location of operator_loc from the source.