Class: SyntaxTree::LambdaVar
Overview
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
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#locals ⇒ Object
readonly
- Array[ Ident ]
-
the list of block-local variable declarations.
-
#params ⇒ Object
readonly
- Params
-
the parameters being declared with the block.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #empty? ⇒ Boolean
- #format(q) ⇒ Object
-
#initialize(params:, locals:, location:, comments: []) ⇒ LambdaVar
constructor
A new instance of LambdaVar.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(params:, locals:, location:, comments: []) ⇒ LambdaVar
6266 6267 6268 6269 6270 6271 |
# File 'lib/syntax_tree/node.rb', line 6266 def initialize(params:, locals:, location:, comments: []) @params = params @locals = locals @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6264 6265 6266 |
# File 'lib/syntax_tree/node.rb', line 6264 def comments @comments end |
#locals ⇒ Object (readonly)
- Array[ Ident ]
-
the list of block-local variable declarations
6261 6262 6263 |
# File 'lib/syntax_tree/node.rb', line 6261 def locals @locals end |
#params ⇒ Object (readonly)
- Params
-
the parameters being declared with the block
6258 6259 6260 |
# File 'lib/syntax_tree/node.rb', line 6258 def params @params end |
Instance Method Details
#accept(visitor) ⇒ Object
6273 6274 6275 |
# File 'lib/syntax_tree/node.rb', line 6273 def accept(visitor) visitor.visit_lambda_var(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
6277 6278 6279 |
# File 'lib/syntax_tree/node.rb', line 6277 def child_nodes [params, *locals] end |
#deconstruct_keys(_keys) ⇒ Object
6283 6284 6285 |
# File 'lib/syntax_tree/node.rb', line 6283 def deconstruct_keys(_keys) { params: params, locals: locals, location: location, comments: comments } end |
#empty? ⇒ Boolean
6287 6288 6289 |
# File 'lib/syntax_tree/node.rb', line 6287 def empty? params.empty? && locals.empty? end |