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

Public Instance methods

[Source]

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

Default stringizing method to emit standard error message.

[Source]

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

Returns error reason. Override this for I18N.

[Source]

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

Pushes back erred argument(s) to argv.

[Source]

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

[Source]

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

Alias for message

[Validate]