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