class SyntaxTree::LambdaVar
LambdaVar
represents the parameters being declared for a lambda. Effectively this node is everything contained within the parentheses. This includes all of the various parameter types, as well as block-local variable declarations.
-> (positional, optional = value, keyword:, █ local) do end
Attributes
- Array[
Ident
] -
the list of block-local variable declarations
Params
-
the parameters being declared with the block
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 7278 def initialize(params:, locals:, location:) @params = params @locals = locals @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 7324 def ===(other) other.is_a?(LambdaVar) && params === other.params && ArrayMatch.call(locals, other.locals) end
Source
# File lib/syntax_tree/node.rb, line 7285 def accept(visitor) visitor.visit_lambda_var(self) end
Source
# File lib/syntax_tree/node.rb, line 7289 def child_nodes [params, *locals] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 7293 def copy(params: nil, locals: nil, location: nil) node = LambdaVar.new( params: params || self.params, locals: locals || self.locals, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 7307 def deconstruct_keys(_keys) { params: params, locals: locals, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 7311 def empty? params.empty? && locals.empty? end
Source
# File lib/syntax_tree/node.rb, line 7315 def format(q) q.format(params) if locals.any? q.text("; ") q.seplist(locals, BlockVar::SEPARATOR) { |local| q.format(local) } end end