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.



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



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_typeObject



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_typeObject



403
404
405
# File 'lib/hammer_cli/options/normalizers.rb', line 403

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

#descriptionObject



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