Class: Cl::UnknownValues

Inherits:
OptionError
  • Object
show all
Includes:
Suggest
Defined in:
lib/cl/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Suggest

#suggest

Constructor Details

#initialize(opts) ⇒ UnknownValues

Returns a new instance of UnknownValues.



106
107
108
109
110
111
112
113
# File 'lib/cl/errors.rb', line 106

def initialize(opts)
  @opts = opts
  opts = opts.map do |(opt, values, known)|
    pairs = values.map { |value| [opt, value].join('=') }.join(' ')
    "#{pairs} (known values: #{known.join(', ')})"
  end
  super(:unknown_values, opts.join(', '))
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



104
105
106
# File 'lib/cl/errors.rb', line 104

def opts
  @opts
end

Instance Method Details

#suggestionsObject



115
116
117
# File 'lib/cl/errors.rb', line 115

def suggestions
  opts.map { |_, value, known| suggest(known, value) }.flatten
end