Returns true
if file_name
is an absolute path, and false
otherwise.
File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
Returns the list of available encoding names.
Encoding.name_list #=> ["US-ASCII", "ASCII-8BIT", "UTF-8", "ISO-8859-1", "Shift_JIS", "EUC-JP", "Windows-31J", "BINARY", "CP932", "eucJP"]
Returns the list of private methods accessible to obj. If the all parameter is set to false
, only those methods in the receiver will be listed.
Returns the path associated with the IO
, or nil
if there is no path associated with the IO
. It is not guaranteed that the path exists on the filesystem.
$stdin.path # => "<STDIN>" File.open("testfile") {|f| f.path} # => "testfile"
Returns a hash representing named captures of self
(see Named Captures):
Each key is the name of a named capture.
Each value is an array of integer indexes for that named capture.
Examples:
/(?<foo>.)(?<bar>.)/.named_captures # => {"foo"=>[1], "bar"=>[2]} /(?<foo>.)(?<foo>.)/.named_captures # => {"foo"=>[1, 2]} /(.)(.)/.named_captures # => {}
Returns the socket path as a string.
Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
Returns a hash of string variables matching the regular expression.
scan = StringScanner.new('foobarbaz') scan.match?(/(?<f>foo)(?<r>bar)(?<z>baz)/) scan.named_captures # -> {"f"=>"foo", "r"=>"bar", "z"=>"baz"}
Sets the date-time format.
Argument datetime_format
should be either of these:
A string suitable for use as a format for method Time#strftime
.
nil
: the logger uses '%Y-%m-%dT%H:%M:%S.%6N'
.
Returns the date-time format; see datetime_format=
.
Returns a hash of the named captures; each key is a capture name; each value is its captured string or nil
:
m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge") # => #<MatchData "hoge" foo:"h" bar:"ge"> m.named_captures # => {"foo"=>"h", "bar"=>"ge"} m = /(?<a>.)(?<b>.)/.match("01") # => #<MatchData "01" a:"0" b:"1"> m.named_captures #=> {"a" => "0", "b" => "1"} m = /(?<a>.)(?<b>.)?/.match("0") # => #<MatchData "0" a:"0" b:nil> m.named_captures #=> {"a" => "0", "b" => nil} m = /(?<a>.)(?<a>.)/.match("01") # => #<MatchData "01" a:"0" a:"1"> m.named_captures #=> {"a" => "1"}
Iterates over all hostnames for address
.
Iterates over all hostnames for address
.
Find
the full path to the executable for gem name
. If the exec_name
is not given, an exception will be raised, otherwise the specified executable’s path is returned. requirements
allows you to specify specific gem versions.
Reset the dir
and path
values. The next time dir
or path
is requested, the values will be calculated from scratch. This is mainly used by the unit tests to provide test isolation.
Use the home
and paths
values for Gem.dir
and Gem.path
. Used mainly by the unit tests to provide environment isolation.
Default gem load path
Prefix and suffix the program filename the same as ruby.
Returns the destination encoding name as a string.
Returns the destination encoding name as a string.
Return the list of all instance variables.
Merges a base path base
, with relative path rel
, returns a modified base path.
Generates new parameters for the algorithm. algo_name is a String
that represents the algorithm. The optional argument options is a Hash
that specifies the options specific to the algorithm. The order of the options can be important.
A block can be passed optionally. The meaning of the arguments passed to the block varies depending on the implementation of the algorithm. The block may be called once or multiple times, or may not even be called.
For the supported options, see the documentation for the ‘openssl genpkey’ utility command.
pkey = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) p pkey.p.num_bits #=> 2048
Returns the name of the cipher which may differ slightly from the original name provided.