Ruby 2.4参考手册
OptionParser
OptionParser::ParseError
父类:RuntimeError
来自OptionParser的异常基类。
常量
Reason
导致错误的原因。
属性
argsR
reasonW
公共类方法
filter_backtrace(array) Show source
# File lib/optparse.rb, line 1966
def self.filter_backtrace(array)
unless $DEBUG
array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
end
array
end
new(*args) Show source
# File lib/optparse.rb, line 1950
def initialize(*args)
@args = args
@reason = nil
end
公共实例方法
inspect() Show source
# File lib/optparse.rb, line 1993
def inspect
"#<#{self.class}: #{args.join(' ')}>"
end
message() Show source
默认字符串化方法发出标准错误信息。
# File lib/optparse.rb, line 2000
def message
reason + ': ' + args.join(' ')
end
另外别名为:to_s
reason() Show source
返回错误原因。覆盖此为I18N。
# File lib/optparse.rb, line 1989
def reason
@reason || self.class::Reason
end
recover(argv) Show source
将错误的参数推回argv
。
# File lib/optparse.rb, line 1961
def recover(argv)
argv[0, 0] = @args
argv
end
set_backtrace(array) Show source
调用超类方法Exception#set_backtrace
# File lib/optparse.rb, line 1973
def set_backtrace(array)
super(self.class.filter_backtrace(array))
end
set_option(opt, eq) Show source
# File lib/optparse.rb, line 1977
def set_option(opt, eq)
if eq
@args[0] = opt
else
@args.unshift(opt)
end
self
end
to_s()
message 的别名
OptionParser相关
Ruby 是一种面向对象、命令式、函数式、动态的通用编程语言,是世界上最优美而巧妙的语言。
主页 | https://www.ruby-lang.org/ |
源码 | https://github.com/ruby/ruby |
版本 | 2.4 |
发布版本 | 2.4.1 |