[フレーム]

Exception: OptionParser::ParseError

Inherits:
RuntimeError
  • Object
  • RuntimeError
  • OptionParser::ParseError
show all
Defined in:
opal/stdlib/optparse.rb

Overview

Base class of exceptions from OptionParser.

Constant Summary collapse

Reason =

Reason which caused the error.

'parse error'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, additional: nil) ⇒ ParseError

Returns a new instance of ParseError.

2066
2067
2068
2069
2070
2071
# File 'opal/stdlib/optparse.rb', line 2066
def initialize(*args, additional: nil)
 @additional = additional
 @arg0, = args
 @args = args
 @reason = nil
end

Instance Attribute Details

#additionalObject

Returns the value of attribute additional.

2075
2076
2077
# File 'opal/stdlib/optparse.rb', line 2075
def additional
 @additional
end

#argsObject (readonly)

Returns the value of attribute args.

2073
2074
2075
# File 'opal/stdlib/optparse.rb', line 2073
def args
 @args
end

#reasonObject

Returns error reason. Override this for I18N.

2108
2109
2110
# File 'opal/stdlib/optparse.rb', line 2108
def reason
 @reason || self.class::Reason
end

Class Method Details

.filter_backtrace(array) ⇒ Object

2085
2086
2087
2088
2089
2090
# File 'opal/stdlib/optparse.rb', line 2085
def self.filter_backtrace(array)
 unless $DEBUG
 array.delete_if(&%r"\A#{Regexp .quote(__FILE__)}:"o.method(:=~))
 end
 array
end

Instance Method Details

#inspectObject

2112
2113
2114
# File 'opal/stdlib/optparse.rb', line 2112
def inspect
 "#<#{self.class}: #{args.join('')}>"
end

#messageObject Also known as: to_s

Default stringizing method to emit standard error message.

2119
2120
2121
# File 'opal/stdlib/optparse.rb', line 2119
def message
 "#{reason}: #{args.join('')}#{additional[@arg0] if additional}"
end

#recover(argv) ⇒ Object

Pushes back erred argument(s) to +argv+.

2080
2081
2082
2083
# File 'opal/stdlib/optparse.rb', line 2080
def recover(argv)
 argv[0, 0] = @args
 argv
end

#set_backtrace(array) ⇒ Object

2092
2093
2094
# File 'opal/stdlib/optparse.rb', line 2092
def set_backtrace(array)
 super(self.class.filter_backtrace(array))
end

#set_option(opt, eq) ⇒ Object

2096
2097
2098
2099
2100
2101
2102
2103
# File 'opal/stdlib/optparse.rb', line 2096
def set_option(opt, eq)
 if eq
 @args[0] = opt
 else
 @args.unshift(opt)
 end
 self
end

AltStyle によって変換されたページ (->オリジナル) /