Returns an array of values from the database.
Returns true
if stat terminated because of an uncaught signal.
Returns the least significant eight bits of the return code of stat. Only available if exited?
is true
.
fork { } #=> 26572 Process.wait #=> 26572 $?.exited? #=> true $?.exitstatus #=> 0 fork { exit 99 } #=> 26573 Process.wait #=> 26573 $?.exited? #=> true $?.exitstatus #=> 99
Wakes up the first thread in line waiting for this lock.
Creates an array of handlers for the given libs
, can be an instance of Fiddle::Handle
, Fiddle::Importer
, or will create a new instance of Fiddle::Handle
using Fiddle.dlopen
Raises a DLError
if the library cannot be loaded.
See Fiddle.dlopen
Sets the type alias for alias_type
as orig_type
Similar to read, but raises EOFError
at end of string instead of returning nil
, as well as IO#sysread
does.
Reads at most maxlen bytes from the stream. If buf is provided it must reference a string which will receive the data.
See IO#readpartial
for full details.
Return true
if the PRNG has been seeded with enough data, false
otherwise.
Start streaming using encoding
Generate a TextArea element, as a String
.
name
is the name of the textarea. cols
is the number of columns and rows
is the number of rows in the display.
Alternatively, the attributes can be specified as a hash.
The body is provided by the passed-in no-argument block
textarea("name") # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) textarea("name", 40, 5) # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5)
Random::Formatter#alphanumeric
generates a random alphanumeric string.
The argument n specifies the length, in characters, of the alphanumeric string to be generated.
If n is not specified or is nil, 16 is assumed. It may be larger in the future.
The result may contain A-Z, a-z and 0-9.
require 'random/formatter' prng.alphanumeric #=> "2BuBuLf3WfSKyQbR" prng.alphanumeric(10) #=> "i6K93NdqiH"
Is local fetching enabled?
Displays an alert statement
. Asks a question
if given.
Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.
Returns whether this dependency, which has no possible matching specifications, can safely be ignored.
@param [Object] dependency @return [Boolean] whether this dependency can safely be skipped.
Replaces the content of self
with the content of other_array
; returns self
:
a = [:foo, 'bar', 2] a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3]
Returns a new Array whose elements are the elements of self
at the given Integer or Range indexes
.
For each positive index
, returns the element at offset index
:
a = [:foo, 'bar', 2] a.values_at(0, 2) # => [:foo, 2] a.values_at(0..1) # => [:foo, "bar"]
The given indexes
may be in any order, and may repeat:
a = [:foo, 'bar', 2] a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2] a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2]
Assigns nil
for an index
that is too large:
a = [:foo, 'bar', 2] a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil]
Returns a new empty Array if no arguments given.
For each negative index
, counts backward from the end of the array:
a = [:foo, 'bar', 2] a.values_at(-1, -3) # => [2, :foo]
Assigns nil
for an index
that is too small:
a = [:foo, 'bar', 2] a.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2]
The given indexes
may have a mixture of signs:
a = [:foo, 'bar', 2] a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2]
Calls the block with each repeated permutation of length n
of the elements of self
; each permutation is an Array; returns self
. The order of the permutations is indeterminate.
When a block and a positive Integer argument n
are given, calls the block with each n
-tuple repeated permutation of the elements of self
. The number of permutations is self.size**n
.
n
= 1:
a = [0, 1, 2] a.repeated_permutation(1) {|permutation| p permutation }
Output:
[0] [1] [2]
n
= 2:
a.repeated_permutation(2) {|permutation| p permutation }
Output:
[0, 0] [0, 1] [0, 2] [1, 0] [1, 1] [1, 2] [2, 0] [2, 1] [2, 2]
If n
is zero, calls the block once with an empty Array.
If n
is negative, does not call the block:
a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' }
Returns a new Enumerator if no block given:
a = [0, 1, 2] a.repeated_permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>
Using Enumerators, it’s convenient to show the permutations and counts for some values of n
:
e = a.repeated_permutation(0) e.size # => 1 e.to_a # => [[]] e = a.repeated_permutation(1) e.size # => 3 e.to_a # => [[0], [1], [2]] e = a.repeated_permutation(2) e.size # => 9 e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]