Class: TTY::Option::Parser::ArityCheck
- Inherits:
-
Object
- Object
- TTY::Option::Parser::ArityCheck
- Defined in:
- lib/tty/option/parser/arity_check.rb
Instance Method Summary collapse
- #add(param) ⇒ Object (also: #<<)
-
#call(arities) ⇒ Object
private
Check if parameter matches arity.
-
#initialize(error_aggregator) ⇒ ArityCheck
constructor
A new instance of ArityCheck.
Constructor Details
#initialize(error_aggregator) ⇒ ArityCheck
Returns a new instance of ArityCheck.
7 8 9 10 |
# File 'lib/tty/option/parser/arity_check.rb', line 7 def initialize(error_aggregator) @multiplies = [] @error_aggregator = error_aggregator end |
Instance Method Details
#add(param) ⇒ Object Also known as: <<
12 13 14 |
# File 'lib/tty/option/parser/arity_check.rb', line 12 def add(param) @multiplies << param end |
#call(arities) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if parameter matches arity
22 23 24 25 26 27 28 29 30 |
# File 'lib/tty/option/parser/arity_check.rb', line 22 def call(arities) @multiplies.each do |param| arity = arities[param.key] if arity < param.min_arity @error_aggregator.(InvalidArity.new(param, arity)) end end end |