instance method
OptionParser::Arguable#getopts
(*::String args) -> ::Hash[::String, untyped]
getopts(*args, symbolize_names: false, **keywords)
lib/optparse.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/optparse.rb, line 2428
def getopts(*args, symbolize_names: false, **keywords)
options.getopts(self, *args, symbolize_names: symbolize_names, **keywords)
end
Substitution of getopts is possible as follows. Also see OptionParser#getopts.
Example
def getopts(*args) ($OPT = ARGV.getopts(*args)).each do |opt, val| eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val" end rescue OptionParser::ParseError end