Class: HammerCLI::Options::Normalizers::EnumList

Inherits:
AbstractNormalizer show all
Defined in:
lib/hammer_cli/options/normalizers.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNormalizer

inherited

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_valuesObject (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_descriptionObject



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_typeObject



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_typeObject



408
409
410
# File 'lib/hammer_cli/options/normalizers.rb', line 408

def completion_type
  super.merge({ values: allowed_values })
end

#descriptionObject



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