Class: HammerCLI::Options::Normalizers::Enum
- Inherits:
-
AbstractNormalizer
- Object
- AbstractNormalizer
- HammerCLI::Options::Normalizers::Enum
- Defined in:
- lib/hammer_cli/options/normalizers.rb
Instance Method Summary collapse
- #complete(value) ⇒ Object
- #description ⇒ Object
- #format(value) ⇒ Object
-
#initialize(allowed_values) ⇒ Enum
constructor
A new instance of Enum.
Constructor Details
#initialize(allowed_values) ⇒ Enum
Returns a new instance of Enum.
142 143 144 |
# File 'lib/hammer_cli/options/normalizers.rb', line 142 def initialize(allowed_values) @allowed_values = allowed_values end |
Instance Method Details
#complete(value) ⇒ Object
158 159 160 |
# File 'lib/hammer_cli/options/normalizers.rb', line 158 def complete(value) Completer::finalize_completions(@allowed_values) end |
#description ⇒ Object
146 147 148 |
# File 'lib/hammer_cli/options/normalizers.rb', line 146 def description _("One of %s") % quoted_values end |
#format(value) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/hammer_cli/options/normalizers.rb', line 150 def format(value) if @allowed_values.include? value value else raise ArgumentError, _("value must be one of '%s'") % quoted_values end end |