Class: Toys::ArgParser::ArgValueUnacceptableError

Inherits:
UsageError
  • Object
show all
Defined in:
lib/toys/arg_parser.rb

Overview

A UsageError indicating a positional argument did not accept the value given it.

Instance Attribute Summary

Attributes inherited from UsageError

#message, #name, #suggestions, #value

Instance Method Summary collapse

Methods inherited from UsageError

#full_message

Constructor Details

#initialize(message = nil, name: nil, value: nil, suggestions: nil) ⇒ ArgValueUnacceptableError

Create an ArgValueUnacceptableError.

Parameters:

  • message (String, nil) (defaults to: nil)

    A custom message. Normally omitted, in which case an appropriate default is supplied.

  • name (String) (defaults to: nil)

    The name of the argument. Normally required.

  • value (String) (defaults to: nil)

    The value given. Normally required.

  • suggestions (Array<String>) (defaults to: nil)

    An array of suggestions to present to the user. Optional.



193
194
195
196
# File 'lib/toys/arg_parser.rb', line 193

def initialize(message = nil, name: nil, value: nil, suggestions: nil)
  super(message || "Unacceptable value \"#{value}\" for positional argument \"#{name}\".",
        name: name, suggestions: suggestions)
end