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 1594
1594:     def initialize(*args)
1595:       @args = args
1596:       @reason = nil
1597:     end

Public Instance methods

[Source]

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

Default stringizing method to emit standard error message.

[Source]

      # File lib/optparse.rb, line 1633
1633:     def message
1634:       reason + ': ' + args.join(' ')
1635:     end

Returns error reason. Override this for I18N.

[Source]

      # File lib/optparse.rb, line 1622
1622:     def reason
1623:       @reason || self.class::Reason
1624:     end

Pushes back erred argument(s) to argv.

[Source]

      # File lib/optparse.rb, line 1605
1605:     def recover(argv)
1606:       argv[0, 0] = @args
1607:       argv
1608:     end

[Source]

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

Alias for message

[Validate]