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.



77
78
79
80
81
# File 'lib/hammer_cli/validator.rb', line 77

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)


83
84
85
86
87
88
# File 'lib/hammer_cli/validator.rb', line 83

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