Class: Recheck::Optimist::Constraint

Inherits:
Object
  • Object
show all
Defined in:
lib/recheck/vendor/optimist.rb

Overview

Abstract class for a constraint. Do not use by itself.

Instance Method Summary collapse

Constructor Details

#initialize(syms) ⇒ Constraint

Returns a new instance of Constraint.



52
53
54
# File 'lib/recheck/vendor/optimist.rb', line 52

def initialize(syms)
  @idents = syms
end

Instance Method Details

#validate(given_args:, specs:) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/recheck/vendor/optimist.rb', line 56

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, error_message(longargs)
  end
end