Returns a new array populated with the values from hsh. See also Hash#keys
.
h = { "a" => 100, "b" => 200, "c" => 300 } h.values #=> [100, 200, 300]
Returns true
if the given value is present for some key in hsh.
h = { "a" => 100, "b" => 200 } h.value?(100) #=> true h.value?(999) #=> false
Returns every environment variable value as an Array
Returns true
if there is an environment variable with the given value
.
Reads at most maxlen bytes from the ARGF
stream.
If the optional outbuf argument is present, it must reference a String, which will receive the data. The outbuf will contain only the received data after the method call even if it is not empty at the beginning.
It raises EOFError
on end of ARGF
stream. Since ARGF
stream is a concatenation of multiple files, internally EOF is occur for each file. ARGF.readpartial
returns empty strings for EOFs except the last one and raises EOFError
for the last one.
Returns the current offset (in bytes) of the current file in ARGF
.
ARGF.pos #=> 0 ARGF.gets #=> "This is line one\n" ARGF.pos #=> 17
Returns a Hash
containing implementation-dependent counters inside the VM.
This hash includes information about method/constant cache serials:
{ :global_method_state=>251, :global_constant_state=>481, :class_serial=>9029 }
The contents of the hash are implementation specific and may be changed in the future.
This method is only expected to work on C Ruby.
This method will return a CSV
instance, just like CSV::new()
, but the instance will be cached and returned for all future calls to this method for the same data
object (tested by Object#object_id()
) with the same options
.
If a block is given, the instance is passed to the block and the return value becomes the return value of the block.
A shortcut for:
CSV.read( path, { headers: true, converters: :numeric, header_converters: :symbol }.merge(options) )
Taint both the object returned by _getobj_ and self.
Untaint both the object returned by _getobj_ and self.
Evaluates the Ruby expression(s) in string, in the binding’s context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors.
def get_binding(param) binding end b = get_binding("hello") b.eval("param") #=> "hello"
Creates a matrix where the diagonal elements are composed of values
.
Matrix.diagonal(9, 5, -3) => 9 0 0 0 5 0 0 0 -3
Creates an n
by n
diagonal matrix where each diagonal element is value
.
Matrix.scalar(2, 5) => 5 0 0 5
Create a matrix by stacking matrices vertically
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] Matrix.vstack(x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
Create a matrix by stacking matrices horizontally
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] Matrix.hstack(x, y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
Returns a matrix that is the result of iteration of the given block over all elements of the matrix.
Matrix[ [1,2], [3,4] ].collect { |e| e**2 } => 1 4 9 16
Returns true
if this is a diagonal matrix. Raises an error if matrix is not square.
Returns true
if this is a normal matrix. Raises an error if matrix is not square.
Returns true
if this is an orthogonal matrix Raises an error if matrix is not square.
Returns true
if this is a permutation matrix Raises an error if matrix is not square.
Returns true
if all entries of the matrix are real.
Returns true
if this is a unitary matrix Raises an error if matrix is not square.
Returns a new matrix resulting by stacking horizontally the receiver with the given matrices
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] x.hstack(y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
Returns a new matrix resulting by stacking vertically the receiver with the given matrices
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] x.vstack(y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]