Method: SyntaxTree::Params#arity
- Defined in:
- lib/syntax_tree/node.rb
#arity ⇒ Object
Returns a range representing the possible number of arguments accepted by this params node not including the block. For example:
def foo(a, b = 1, c:, d: 2, &block)
...
end
has arity 2..4.
8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 |
# File 'lib/syntax_tree/node.rb', line 8466 def arity optional_keywords = keywords.count { |_label, value| value } lower_bound = requireds.length + posts.length + keywords.length - optional_keywords upper_bound = if keyword_rest.nil? && rest.nil? lower_bound + optionals.length + optional_keywords end lower_bound..upper_bound end |