Closes the current file and skips to the next file in ARGV. If there are no more files to open, just closes the current file. STDIN will not be closed.
For example:
$ ruby argf.rb foo bar ARGF.filename #=> "foo" ARGF.close ARGF.filename #=> "bar" ARGF.close
Returns true if the current file has been closed; false otherwise. Use ARGF.close
to actually close the current file.
This method must be overridden by subclasses and should return the object method calls are being delegated to.
Returns the current object method calls are being delegated to.
Returns revision information for the erb.rb module.
Sets optional filename and line number that will be used in ERB
code evaluation and error reporting. See also filename=
and lineno=
erb = ERB.new('<%= some_x %>') erb.render # undefined local variable or method `some_x' # from (erb):1 erb.location = ['file.erb', 3] # All subsequent error reporting would use new location erb.render # undefined local variable or method `some_x' # from file.erb:4
Returns true if the ipaddr is a loopback address. Loopback IPv4 addresses in the IPv4-mapped IPv6 address range are also considered as loopback addresses.
Returns a string for DNS reverse lookup. It returns a string in RFC3172 form for an IPv6 address.
Terminates option parsing. Optional parameter arg
is a string pushed back to be the first non-option argument.
Heading banner preceding summary.
Returns version string from program_name
, version and release.
Parses command line arguments argv
in order. When a block is given, each non-option argument is yielded. When optional into
keyword argument is provided, the parsed option values are stored there via []=
method (so it can be Hash
, or OpenStruct
, or other similar object).
Returns the rest of argv
left unparsed.
Same as order
, but removes switches destructively. Non-option arguments remain in argv
.
Parses command line arguments argv
in permutation mode and returns list of non-option arguments. When optional into
keyword argument is provided, the parsed option values are stored there via []=
method (so it can be Hash
, or OpenStruct
, or other similar object).
Same as permute
, but removes switches destructively. Non-option arguments remain in argv
.
Wrapper method for getopts.rb.
params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option") # params["a"] = true # -a # params["b"] = "1" # -b1 # params["foo"] = "1" # --foo # params["bar"] = "x" # --bar x # params["zot"] = "z" # --zot Z
Option symbolize_names
(boolean) specifies whether returned Hash
keys should be Symbols; defaults to false
(use Strings).
params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true) # params[:a] = true # -a # params[:b] = "1" # -b1 # params[:foo] = "1" # --foo # params[:bar] = "x" # --bar x # params[:zot] = "z" # --zot Z
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.
The optional into
keyword argument works exactly like that accepted in method parse
.
Returns an array of member names of the data class:
Measure = Data.define(:amount, :unit) Measure.members # => [:amount, :unit]
Returns the member names from self
as an array:
Measure = Data.define(:amount, :unit) distance = Measure[10, 'km'] distance.members #=> [:amount, :unit]
Returns the regexp that produced the match:
m = /a.*b/.match("abc") # => #<MatchData "ab"> m.regexp # => /a.*b/
Looks up the first IP address for name
.