W3cubDocs

/Ruby 2.4

class OptionParser::ParseError

Parent:
RuntimeError

Base class of exceptions from OptionParser.

Constants

Reason

Reason which caused the error.

Attributes

args[R]
reason[W]

Public Class Methods

filter_backtrace(array) Show source
# File lib/optparse.rb, line 1966
def self.filter_backtrace(array)
  unless $DEBUG
    array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
  end
  array
end
new(*args) Show source
# File lib/optparse.rb, line 1950
def initialize(*args)
  @args = args
  @reason = nil
end

Public Instance Methods

inspect() Show source
# File lib/optparse.rb, line 1993
def inspect
  "#<#{self.class}: #{args.join(' ')}>"
end
message() Show source

Default stringizing method to emit standard error message.

# File lib/optparse.rb, line 2000
def message
  reason + ': ' + args.join(' ')
end
Also aliased as: to_s
reason() Show source

Returns error reason. Override this for I18N.

# File lib/optparse.rb, line 1989
def reason
  @reason || self.class::Reason
end
recover(argv) Show source

Pushes back erred argument(s) to argv.

# File lib/optparse.rb, line 1961
def recover(argv)
  argv[0, 0] = @args
  argv
end
set_backtrace(array) Show source
Calls superclass method Exception#set_backtrace
# File lib/optparse.rb, line 1973
def set_backtrace(array)
  super(self.class.filter_backtrace(array))
end
set_option(opt, eq) Show source
# File lib/optparse.rb, line 1977
def set_option(opt, eq)
  if eq
    @args[0] = opt
  else
    @args.unshift(opt)
  end
  self
end
to_s()
Alias for: message

Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.