Class: HammerCLI::Validator::AnyConstraint

Inherits:
BaseConstraint show all
Defined in:
lib/hammer_cli/validator.rb

Instance Attribute Summary

Attributes inherited from BaseConstraint

#rejected_msg, #required_msg

Instance Method Summary collapse

Methods inherited from BaseConstraint

#rejected, #required

Constructor Details

#initialize(options, to_check) ⇒ AnyConstraint

Returns a new instance of AnyConstraint.



98
99
100
101
102
# File 'lib/hammer_cli/validator.rb', line 98

def initialize(options, to_check)
  super(options, to_check)
  @rejected_msg = _("You can't set any of options %s.")
  @required_msg = _("At least one of options %s is required.")
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


104
105
106
107
108
109
# File 'lib/hammer_cli/validator.rb', line 104

def exist?
  @to_check.each do |opt|
    return true if option_passed?(opt)
  end
  return @to_check.empty?
end