Class: Cl::Opts::Validate::Requires
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
#apply ⇒ Object
53
54
55
|
# File 'lib/cl/opts/validate.rb', line 53
def apply
raise RequiresOpts.new(invert(missing)) if missing.any?
end
|
#missing ⇒ Object
57
58
59
60
61
62
|
# File 'lib/cl/opts/validate.rb', line 57
def missing
@missing ||= requires.map do |opt|
missing = opt.requires.select { |key| !values.key?(key) }
[opt.name, missing] if missing.any?
end.compact
end
|
#requires ⇒ Object
64
65
66
|
# File 'lib/cl/opts/validate.rb', line 64
def requires
opts.select(&:requires?).select { |opt| orig.key?(opt.name) }
end
|