123456789_123456789_123456789_123456789_123456789_

Exception: OptionParser::ParseError

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, RuntimeError
Instance Chain:
self, RuntimeError
Inherits: RuntimeError
  • Object
Defined in: lib/optparse.rb

Overview

Base class of exceptions from ::OptionParser.

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(*args) ⇒ ParseError

[ GitHub ]

  
# File 'lib/optparse.rb', line 1800

def initialize(*args)
  @args = args
  @reason = nil
end

Class Method Details

.filter_backtrace(array)

[ GitHub ]

  
# File 'lib/optparse.rb', line 1816

def self.filter_backtrace(array)
  unless $DEBUG
    array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
  end
  array
end

Instance Attribute Details

#args (readonly)

[ GitHub ]

  
# File 'lib/optparse.rb', line 1805

attr_reader :args

#reason (rw)

Returns error reason. Override this for I18N.

[ GitHub ]

  
# File 'lib/optparse.rb', line 1839

def reason
  @reason || self.class::Reason
end

#reason=(value) (rw)

[ GitHub ]

  
# File 'lib/optparse.rb', line 1806

attr_writer :reason

Instance Method Details

#inspect

[ GitHub ]

  
# File 'lib/optparse.rb', line 1843

def inspect
  "#<#{self.class}: #{args.join(' ')}>"
end

#message Also known as: #to_s

Default stringizing method to emit standard error message.

[ GitHub ]

  
# File 'lib/optparse.rb', line 1850

def message
  reason + ': ' + args.join(' ')
end

#recover(argv)

Pushes back erred argument(s) to argv.

[ GitHub ]

  
# File 'lib/optparse.rb', line 1811

def recover(argv)
  argv[0, 0] = @args
  argv
end

#set_backtrace(array)

[ GitHub ]

  
# File 'lib/optparse.rb', line 1823

def set_backtrace(array)
  super(self.class.filter_backtrace(array))
end

#set_option(opt, eq)

[ GitHub ]

  
# File 'lib/optparse.rb', line 1827

def set_option(opt, eq)
  if eq
    @args[0] = opt
  else
    @args.unshift(opt)
  end
  self
end

#to_s

Alias for #message.

[ GitHub ]

  
# File 'lib/optparse.rb', line 1854

alias to_s message