BlockVar
represents the parameters being declared for a block. Effectively this node is everything contained within the pipes. This includes all of the various parameter types, as well as block-local variable declarations.
method do |positional, optional = value, keyword:, █ local| endConstants
We’ll keep a single instance of this separator around for all block vars to cut down on allocations.
Ident
]
the list of block-local variable declarations
Params
the parameters being declared with the block
def initialize(params:, locals:, location:) @params = params @locals = locals @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(BlockVar) && params === other.params && ArrayMatch.call(locals, other.locals) endSource
def accept(visitor) visitor.visit_block_var(self) endSource
def arg0? params.requireds.length == 1 && params.optionals.empty? && params.rest.nil? && params.posts.empty? && params.keywords.empty? && params.keyword_rest.nil? && params.block.nil? end
When
a single required parameter is declared for a block, it gets automatically expanded if the values being yielded into it are an array.
def child_nodes [params, *locals] endSource
def copy(params: nil, locals: nil, location: nil) node = BlockVar.new( params: params || self.params, locals: locals || self.locals, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node endSource
def deconstruct_keys(_keys) { params: params, locals: locals, location: location, comments: comments } endSource
def format(q) q.text("|") q.group do q.remove_breaks(q.format(params)) if locals.any? q.text("; ") q.seplist(locals, SEPARATOR) { |local| q.format(local) } end end q.text("|") end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4