Class: HammerCLI::Options::Normalizers::EnumList
- Inherits:
-
AbstractNormalizer
- Object
- AbstractNormalizer
- HammerCLI::Options::Normalizers::EnumList
- Defined in:
- lib/hammer_cli/options/normalizers.rb
Instance Attribute Summary collapse
-
#allowed_values ⇒ Object
readonly
Returns the value of attribute allowed_values.
Class Method Summary collapse
Instance Method Summary collapse
- #complete(value) ⇒ Object
- #completion_type ⇒ Object
- #description ⇒ Object
- #format(value) ⇒ Object
-
#initialize(allowed_values) ⇒ EnumList
constructor
A new instance of EnumList.
Methods inherited from AbstractNormalizer
Constructor Details
#initialize(allowed_values) ⇒ EnumList
Returns a new instance of EnumList.
390 391 392 |
# File 'lib/hammer_cli/options/normalizers.rb', line 390 def initialize(allowed_values) @allowed_values = allowed_values end |
Instance Attribute Details
#allowed_values ⇒ Object (readonly)
Returns the value of attribute allowed_values.
388 389 390 |
# File 'lib/hammer_cli/options/normalizers.rb', line 388 def allowed_values @allowed_values end |
Class Method Details
.common_description ⇒ Object
383 384 385 |
# File 'lib/hammer_cli/options/normalizers.rb', line 383 def common_description _("Any combination of possible values described in the option's description") end |
.completion_type ⇒ Object
379 380 381 |
# File 'lib/hammer_cli/options/normalizers.rb', line 379 def completion_type :multienum end |
Instance Method Details
#complete(value) ⇒ Object
402 403 404 |
# File 'lib/hammer_cli/options/normalizers.rb', line 402 def complete(value) Completer::finalize_completions(@allowed_values) end |
#completion_type ⇒ Object
406 407 408 |
# File 'lib/hammer_cli/options/normalizers.rb', line 406 def completion_type super.merge({ values: allowed_values }) end |
#description ⇒ Object
394 395 396 |
# File 'lib/hammer_cli/options/normalizers.rb', line 394 def description _("Any combination (comma separated list) of '%s'") % quoted_values end |
#format(value) ⇒ Object
398 399 400 |
# File 'lib/hammer_cli/options/normalizers.rb', line 398 def format(value) value.is_a?(String) ? parse(value) : [] end |