Class: HammerCLI::Validator::OneOfConstraint
- Inherits:
-
BaseConstraint
- Object
- BaseConstraint
- HammerCLI::Validator::OneOfConstraint
- Defined in:
- lib/hammer_cli/validator.rb
Instance Attribute Summary
Attributes inherited from BaseConstraint
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(options, to_check) ⇒ OneOfConstraint
constructor
A new instance of OneOfConstraint.
- #rejected ⇒ Object
- #required_msg ⇒ Object
Methods inherited from BaseConstraint
Constructor Details
#initialize(options, to_check) ⇒ OneOfConstraint
Returns a new instance of OneOfConstraint.
114 115 116 117 |
# File 'lib/hammer_cli/validator.rb', line 114 def initialize(, to_check) raise 'Set at least one expected option' if to_check.empty? super(, to_check) end |
Instance Method Details
#exist? ⇒ Boolean
134 135 136 |
# File 'lib/hammer_cli/validator.rb', line 134 def exist? return == 1 end |
#rejected ⇒ Object
119 120 121 |
# File 'lib/hammer_cli/validator.rb', line 119 def rejected raise NotImplementedError, '#rejected is unsupported for OneOfConstraint' end |
#required_msg ⇒ Object
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/hammer_cli/validator.rb', line 123 def required_msg case when 0 _("One of options %s is required.") when 1 '' else _("Only one of options %s can be set.") end end |