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 1597
1597:     def initialize(*args)
1598:       @args = args
1599:       @reason = nil
1600:     end

Public Instance methods

[Source]

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

Default stringizing method to emit standard error message.

[Source]

      # File lib/optparse.rb, line 1636
1636:     def message
1637:       reason + ': ' + args.join(' ')
1638:     end

Returns error reason. Override this for I18N.

[Source]

      # File lib/optparse.rb, line 1625
1625:     def reason
1626:       @reason || self.class::Reason
1627:     end

Pushes back erred argument(s) to argv.

[Source]

      # File lib/optparse.rb, line 1608
1608:     def recover(argv)
1609:       argv[0, 0] = @args
1610:       argv
1611:     end

[Source]

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

Alias for message

[Validate]