Class: TTY::Option::Parser::RequiredCheck
- Inherits:
-
Object
- Object
- TTY::Option::Parser::RequiredCheck
- Defined in:
- lib/tty/option/parser/required_check.rb
Instance Method Summary collapse
- #add(param) ⇒ Object (also: #<<)
-
#call ⇒ Object
Check if required options are provided.
- #delete(param) ⇒ Object
-
#initialize(error_aggregator) ⇒ RequiredCheck
constructor
A new instance of RequiredCheck.
Constructor Details
#initialize(error_aggregator) ⇒ RequiredCheck
Returns a new instance of RequiredCheck.
7 8 9 10 |
# File 'lib/tty/option/parser/required_check.rb', line 7 def initialize(error_aggregator) @required = [] @error_aggregator = error_aggregator end |
Instance Method Details
#add(param) ⇒ Object Also known as: <<
12 13 14 |
# File 'lib/tty/option/parser/required_check.rb', line 12 def add(param) @required << param end |
#call ⇒ Object
Check if required options are provided
26 27 28 29 30 31 32 |
# File 'lib/tty/option/parser/required_check.rb', line 26 def call return if @required.empty? @required.each do |param| @error_aggregator.(MissingParameter.new(param)) end end |
#delete(param) ⇒ Object
17 18 19 |
# File 'lib/tty/option/parser/required_check.rb', line 17 def delete(param) @required.delete(param) end |