module Pipeful::ArityRange
an extension rather than a refinement so that it can be patched in on a per-object basis rather than having to specify every class that needs it (Method, UnboundMethod, and Proc at least)
Public Instance Methods
arity_range(subtract: 0)
click to toggle source
# File lib/pipeful.rb, line 54 def arity_range(subtract: 0) min_arity = parameters.select { |type, _name| type == :req } .count - subtract if parameters.assoc(:rest) max_arity = Float::INFINITY else max_arity = min_arity + parameters.select { |type, _name| type == :opt } .count end min_arity..max_arity end