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 385 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 381 def completion_type :multienum end
new(allowed_values)
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 392 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 404 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 408 def completion_type super.merge({ values: allowed_values }) end
description()
click to toggle source
# File lib/hammer_cli/options/normalizers.rb, line 396 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 400 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 418 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 414 def quoted_values @allowed_values.map { |v| "'#{v}'" }.join(', ') end