Exception: Toys::ArgParser::ExtraArgumentsError

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

Overview

A UsageError indicating extra arguments were supplied.

Instance Attribute Summary collapse

Attributes inherited from UsageError

#message, #name, #suggestions, #value

Instance Method Summary collapse

Methods inherited from UsageError

#message_with_suggestions

Constructor Details

#initialize(message = nil, arguments: nil) ⇒ ExtraArgumentsError

Create an ExtraArgumentsError.

Parameters:

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

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

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

    All extra arguments. Normally required.



235
236
237
238
239
# File 'lib/toys/arg_parser.rb', line 235

def initialize(message = nil, arguments: nil)
  @arguments = Array(arguments)
  super(message || "Extra arguments: \"#{@arguments.join(' ')}\".",
        value: @arguments.first, skip_frames: 1)
end

Instance Attribute Details

#argumentsArray<String> (readonly)

Returns All extra arguments.

Returns:

  • (Array<String>)

    All extra arguments



244
245
246
# File 'lib/toys/arg_parser.rb', line 244

def arguments
  @arguments
end