Class ParseError
In: lib/optparse.rb
Parent: RuntimeError

Base class of exceptions from OptionParser.

Methods

inspect   message   new   reason   recover   set_option   to_s  

Constants

Reason = 'parse error'.freeze   Reason which caused the error.

Attributes

args  [R] 
reason  [W] 

Public Class methods

[Source]

      # File lib/optparse.rb, line 1591
1591:     def initialize(*args)
1592:       @args = args
1593:       @reason = nil
1594:     end

Public Instance methods

[Source]

      # File lib/optparse.rb, line 1623
1623:     def inspect
1624:       "#<#{self.class.to_s}: #{args.join(' ')}>"
1625:     end

Default stringizing method to emit standard error message.

[Source]

      # File lib/optparse.rb, line 1630
1630:     def message
1631:       reason + ': ' + args.join(' ')
1632:     end

Returns error reason. Override this for I18N.

[Source]

      # File lib/optparse.rb, line 1619
1619:     def reason
1620:       @reason || self.class::Reason
1621:     end

Pushes back erred argument(s) to argv.

[Source]

      # File lib/optparse.rb, line 1602
1602:     def recover(argv)
1603:       argv[0, 0] = @args
1604:       argv
1605:     end

[Source]

      # File lib/optparse.rb, line 1607
1607:     def set_option(opt, eq)
1608:       if eq
1609:         @args[0] = opt
1610:       else
1611:         @args.unshift(opt)
1612:       end
1613:       self
1614:     end
to_s()

Alias for message

[Validate]