Returns an incremented value of default
according to arg
.
Initializes the instance and yields itself if called with a block.
banner
Banner message.
width
Summary width.
indent
Summary indent.
Directs to reject specified class argument.
t
Argument class specifier, any object including Class
.
reject(t)
Pushes a new List
.
Removes the last List
.
Returns option summary string.
Checks if an argument is given twice, in which case an ArgumentError
is raised. Called from OptionParser#switch only.
obj
New argument.
prv
Previously specified argument.
msg
Exception
message.
Traverses @stack, sending each element method id
with args
and block
.
Completes shortened long style option switch and returns pair of canonical switch and switch descriptor OptionParser::Switch
.
typ
Searching table.
opt
Searching key.
icase
Search case insensitive if true.
pat
Optional pattern for completion.
Loads options from file names as filename
. Does nothing when the file is not present. Returns whether successfully loaded.
filename
defaults to basename of the program without suffix in a directory ~/.options, then the basename with ‘.options’ suffix under XDG and Haiku standard places.
Add option switch like with on
, but at head of summary.
Add option switch like with on
, but at tail of summary.
Sets OptionParser
object, when opt
is false
or nil
, methods OptionParser::Arguable#options
and OptionParser::Arguable#options=
are undefined. Thus, there is no ways to access the OptionParser
object via the receiver object.
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.
Parses self
destructively and returns self
containing the rest arguments left unparsed.
Searches key
in id
list. The result is returned or yielded if a block is given. If it isn’t found, nil is returned.
Substitution of getopts is possible as follows. Also see OptionParser#getopts
.
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