Class: Optimist::Constraint
- Inherits:
-
Object
- Object
- Optimist::Constraint
- Defined in:
- lib/optimist.rb
Overview
Abstract class for a constraint. Do not use by itself.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(syms) ⇒ Constraint
constructor
A new instance of Constraint.
- #validate(given_args:, specs:) ⇒ Object
Constructor Details
#initialize(syms) ⇒ Constraint
Returns a new instance of Constraint.
42 43 44 |
# File 'lib/optimist.rb', line 42 def initialize(syms) @idents = syms end |
Instance Method Details
#validate(given_args:, specs:) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/optimist.rb', line 45 def validate(given_args:, specs:) overlap = @idents & given_args.keys if error_condition(overlap.size) longargs = @idents.map { |sym| "--#{specs[sym].long.long}" } raise CommandlineError, (longargs) end end |