Class: TTY::Option::Parser::RequiredCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/option/parser/required_check.rb

Instance Method Summary collapse

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

#callObject

Check if required options are provided

Raises:



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