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.
387 388 389 |
# File 'lib/hammer_cli/options/normalizers.rb', line 387 def initialize(allowed_values) @allowed_values = allowed_values end |
Instance Attribute Details
#allowed_values ⇒ Object (readonly)
Returns the value of attribute allowed_values.
385 386 387 |
# File 'lib/hammer_cli/options/normalizers.rb', line 385 def allowed_values @allowed_values end |
Class Method Details
.common_description ⇒ Object
380 381 382 |
# File 'lib/hammer_cli/options/normalizers.rb', line 380 def common_description _("Any combination of possible values described in the option's description") end |
.completion_type ⇒ Object
376 377 378 |
# File 'lib/hammer_cli/options/normalizers.rb', line 376 def completion_type :multienum end |
Instance Method Details
#complete(value) ⇒ Object
399 400 401 |
# File 'lib/hammer_cli/options/normalizers.rb', line 399 def complete(value) Completer::finalize_completions(@allowed_values) end |
#completion_type ⇒ Object
403 404 405 |
# File 'lib/hammer_cli/options/normalizers.rb', line 403 def completion_type super.merge({ values: allowed_values }) end |
#description ⇒ Object
391 392 393 |
# File 'lib/hammer_cli/options/normalizers.rb', line 391 def description _("Any combination (comma separated list) of '%s'") % quoted_values end |
#format(value) ⇒ Object
395 396 397 |
# File 'lib/hammer_cli/options/normalizers.rb', line 395 def format(value) value.is_a?(String) ? parse(value) : [] end |