Class: HammerCLI::Options::Validators::DSL::OneOfConstraint
- Inherits:
-
BaseConstraint
- Object
- BaseConstraint
- HammerCLI::Options::Validators::DSL::OneOfConstraint
- Defined in:
- lib/hammer_cli/options/validators/dsl.rb
Instance Attribute Summary
Attributes inherited from BaseConstraint
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(options, option_values, to_check) ⇒ OneOfConstraint
constructor
A new instance of OneOfConstraint.
- #rejected ⇒ Object
- #required_msg ⇒ Object
Methods inherited from BaseConstraint
Constructor Details
#initialize(options, option_values, to_check) ⇒ OneOfConstraint
Returns a new instance of OneOfConstraint.
101 102 103 104 |
# File 'lib/hammer_cli/options/validators/dsl.rb', line 101 def initialize(, option_values, to_check) raise 'Set at least one expected option' if to_check.empty? super end |
Instance Method Details
#exist? ⇒ Boolean
121 122 123 |
# File 'lib/hammer_cli/options/validators/dsl.rb', line 121 def exist? return == 1 end |
#rejected ⇒ Object
106 107 108 |
# File 'lib/hammer_cli/options/validators/dsl.rb', line 106 def rejected raise NotImplementedError, '#rejected is unsupported for OneOfConstraint' end |
#required_msg ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/hammer_cli/options/validators/dsl.rb', line 110 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 |