Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false otherwise.
Returns true for IPv4-compatible IPv6 address (::/80). It returns false otherwise.
Returns the socket path as a string.
Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
This returns the value that scan_until
would return, without advancing the scan pointer. The match register is affected, though.
s = StringScanner.new("Fri Dec 12 1975 14:39") s.check_until /12/ # -> "Fri Dec 12" s.pos # -> 0 s.matched # -> 12
Mnemonic: it “checks” to see whether a scan_until
will return a value.
Scans the string until the pattern
is matched. Advances the scan pointer if advance_pointer_p
, otherwise not. Returns the matched string if return_string_p
is true, otherwise returns the number of bytes advanced. This method does affect the match register.
Returns the subgroups in the most recent match at the given indices. If nothing was priorly matched, it returns nil.
s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.values_at 0, -1, 5, 2 # -> ["Fri Dec 12 ", "12", nil, "Dec"] s.scan(/(\w+) (\w+) (\d+) /) # -> nil s.values_at 0, -1, 5, 2 # -> nil
Whether scanner
uses fixed anchor mode or not.
If fixed anchor mode is used, \A
always matches the beginning of the string. Otherwise, \A
always matches the current position.
Creates GUID.
WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8}
Returns major version.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.major_version # => 8
Returns the type library major version.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.major_version # -> 1
Calls block once for each key in hsh, passing the value as a parameter.
If no block is given, an enumerator is returned instead.
h = { "a" => 100, "b" => 200 } h.each_value {|value| puts value }
produces:
100 200
Calls block once for each key in hsh, passing the key as a parameter.
If no block is given, an enumerator is returned instead.
h = { "a" => 100, "b" => 200 } h.each_key {|key| puts key }
produces:
a b
Calls block once for each key in hsh, passing the key-value pair as parameters.
If no block is given, an enumerator is returned instead.
h = { "a" => 100, "b" => 200 } h.each {|key, value| puts "#{key} is #{value}" }
produces:
a is 100 b is 200
Return an array containing the values associated with the given keys. Also see Hash.select
.
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.values_at("cow", "cat") #=> ["bovine", "feline"]
Yields each environment variable name and its value as a 2-element Array:
h = {} ENV.each_pair { |name, value| h[name] = value } # => ENV h # => {"bar"=>"1", "foo"=>"0"}
Returns an Enumerator
if no block given:
h = {} e = ENV.each_pair # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_pair> e.each { |name, value| h[name] = value } # => ENV h # => {"bar"=>"1", "foo"=>"0"}
Yields each environment variable name:
ENV.replace('foo' => '0', 'bar' => '1') # => ENV names = [] ENV.each_key { |name| names.push(name) } # => ENV names # => ["bar", "foo"]
Returns an Enumerator
if no block given:
e = ENV.each_key # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_key> names = [] e.each { |name| names.push(name) } # => ENV names # => ["bar", "foo"]
Yields each environment variable value:
ENV.replace('foo' => '0', 'bar' => '1') # => ENV values = [] ENV.each_value { |value| values.push(value) } # => ENV values # => ["1", "0"]
Returns an Enumerator
if no block given:
e = ENV.each_value # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_value> values = [] e.each { |value| values.push(value) } # => ENV values # => ["1", "0"]
Returns an array containing the environment variable values associated with the given names. See also ENV.select
.
Returns an enumerator which iterates over each line (separated by sep, which defaults to your platform’s newline character) of each file in ARGV
. If a block is supplied, each line in turn will be yielded to the block, otherwise an enumerator is returned. The optional limit argument is an Integer
specifying the maximum length of each line; longer lines will be split according to this limit.
This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last line of the first file has been returned, the first line of the second file is returned. The ARGF.filename
and ARGF.lineno
methods can be used to determine the filename of the current line and line number of the whole input, respectively.
For example, the following code prints out each line of each named file prefixed with its line number, displaying the filename once per file:
ARGF.each_line do |line| puts ARGF.filename if ARGF.file.lineno == 1 puts "#{ARGF.file.lineno}: #{line}" end
While the following code prints only the first file’s name at first, and the contents with line number counted through all named files.
ARGF.each_line do |line| puts ARGF.filename if ARGF.lineno == 1 puts "#{ARGF.lineno}: #{line}" end
Iterates over each byte of each file in ARGV
. A byte is returned as an Integer
in the range 0..255.
This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last byte of the first file has been returned, the first byte of the second file is returned. The ARGF.filename
method can be used to determine the filename of the current byte.
If no block is given, an enumerator is returned instead.
For example:
ARGF.bytes.to_a #=> [35, 32, ... 95, 10]
Iterates over each codepoint of each file in ARGF
.
This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last codepoint of the first file has been returned, the first codepoint of the second file is returned. The ARGF.filename
method can be used to determine the name of the file in which the current codepoint appears.
If no block is given, an enumerator is returned instead.
Return the accept character set for all new CGI
instances.