class HammerCLI::Validator::OneOfConstraint
Public Class Methods
new(options, to_check)
click to toggle source
Calls superclass method
HammerCLI::Validator::BaseConstraint.new
# File lib/hammer_cli/validator.rb, line 104 def initialize(options, to_check) raise 'Set at least one expected option' if to_check.empty? super(options, to_check) end
Public Instance Methods
exist?()
click to toggle source
# File lib/hammer_cli/validator.rb, line 124 def exist? return count_present_options == 1 end
rejected()
click to toggle source
# File lib/hammer_cli/validator.rb, line 109 def rejected raise NotImplementedError, '#rejected is unsupported for OneOfConstraint' end
required_msg()
click to toggle source
# File lib/hammer_cli/validator.rb, line 113 def required_msg case count_present_options when 0 _("One of options %s is required") when 1 '' else _("Only one of options %s can be set") end end
Protected Instance Methods
count_present_options()
click to toggle source
# File lib/hammer_cli/validator.rb, line 129 def count_present_options @to_check.count do |opt| option_passed?(opt) end end