Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
OptionParser::Arguable#options
() -> ::OptionParser
[T] () { (::OptionParser) -> T } -> T?
options() { |optparse| ... }
lib/optparse.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/optparse.rb, line 2387
def options
@optparse ||= OptionParser.new
@optparse.default_argv = self
block_given? or return @optparse
begin
yield @optparse
rescue ParseError
@optparse.warn $!
nil
end
end
Actual OptionParser object, automatically created if nonexistent.
If called with a block, yields the OptionParser object and returns the result of the block. If an OptionParser::ParseError exception occurs in the block, it is rescued, a error message printed to STDERR and nil returned.