class HammerCLI::Options::Normalizers::EnumList
Attributes
allowed_values[R]
Public Class Methods
common_description()
click to toggle source
# 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()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 376 def completion_type :multienum end
new(allowed_values)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 387 def initialize(allowed_values) @allowed_values = allowed_values end
Public Instance Methods
complete(value)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 399 def complete(value) Completer::finalize_completions(@allowed_values) end
completion_type()
click to toggle source
Calls superclass method
HammerCLI::Options::Normalizers::AbstractNormalizer::completion_type
# File lib/hammer_cli/options/normalizers.rb, line 403 def completion_type super.merge({ values: allowed_values }) end
description()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 391 def description _("Any combination (comma separated list) of '%s'") % quoted_values end
format(value)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 395 def format(value) value.is_a?(String) ? parse(value) : [] end
Private Instance Methods
parse(arr)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 413 def parse(arr) arr.split(",").uniq.tap do |values| unless values.inject(true) { |acc, cur| acc & (@allowed_values.include? cur) } raise ArgumentError, _("Value must be a combination of '%s'.") % quoted_values end end end
quoted_values()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 409 def quoted_values @allowed_values.map { |v| "'#{v}'" }.join(', ') end