Class: Cl::Opts::Validate::Required

Inherits:
Validator
  • Object
show all
Defined in:
lib/cl/opts/validate.rb

Instance Attribute Summary

Attributes inherited from Validator

#cmd, #opts, #orig, #values

Instance Method Summary collapse

Methods inherited from Validator

#compact, #invert, #only

Methods included from Regex

#format_regex

Instance Method Details

#applyObject

Raises:



30
31
32
33
# File 'lib/cl/opts/validate.rb', line 30

def apply
  # make sure we do not accept unnamed required options
  raise RequiredOpts.new(missing.map(&:name)) if missing.any?
end

#missingObject



35
36
37
# File 'lib/cl/opts/validate.rb', line 35

def missing
  @missing ||= opts.select(&:required?).select { |opt| !values.key?(opt.name) }
end