class HammerCLI::Options::Normalizers::Enum
Attributes
allowed_values[R]
Public Class Methods
new(allowed_values)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 172 def initialize(allowed_values) @allowed_values = allowed_values end
Public Instance Methods
complete(value)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 193 def complete(value) Completer::finalize_completions(@allowed_values) end
description()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 176 def description _("Possible value(s): %s") % quoted_values end
format(value)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 180 def format(value) if @allowed_values.include? value value else if allowed_values.count == 1 msg = _("value must be %s") % quoted_values else msg = _("value must be one of %s") % quoted_values end raise ArgumentError, msg end end
Private Instance Methods
quoted_values()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 199 def quoted_values @allowed_values.map { |v| "'#{v}'" }.join(', ') end