Returns the ARGV
array, which contains the arguments passed to your script, one per element.
For example:
$ ruby argf.rb -v glark.txt ARGF.argv #=> ["-v", "glark.txt"]
This is a deprecated alias for each_char
.
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.
Reads the next character from ARGF
and returns it as a String
. Raises an EOFError
after the last character of the last file has been read.
For example:
$ echo "foo" > file $ ruby argf.rb file ARGF.readchar #=> "f" ARGF.readchar #=> "o" ARGF.readchar #=> "o" ARGF.readchar #=> "\n" ARGF.readchar #=> end of file reached (EOFError)
Parse an HTTP query string into a hash of key=>value pairs.
params = CGI::parse("query_string") # {"name1" => ["value1", "value2", ...], # "name2" => ["value1", "value2", ...], ... }
This method wraps a String you provide, or an empty default String, in a CSV
object which is passed to the provided block. You can use the block to append CSV
rows to the String and when the block exits, the final String will be returned.
Note that a passed String is modified by this method. Call dup() before passing if you need a new String.
The options
parameter can be anything CSV::new()
understands. This method understands an additional :encoding
parameter when not passed a String to set the base Encoding
for the output. CSV
needs this hint if you plan to output non-ASCII compatible data.
This method can be used to easily parse CSV
out of a String. You may either provide a block
which will be called with each row of the String in turn, or just use the returned Array of Arrays (when no block
is given).
You pass your str
to read from, and an optional options
Hash
containing anything CSV::new()
understands.
Use __raise__ if your Delegator
does not have a object to delegate the raise method call.
Returns true
iff the current severity level allows for the printing of WARN
messages.
Returns true
iff the current severity level allows for the printing of ERROR
messages.
Creates an n
by n
diagonal matrix where each diagonal element is value
.
Matrix.scalar(2, 5) => 5 0 0 5
Returns true
if this is a regular (i.e. non-singular) matrix.
Returns true
if this is a singular matrix.
Returns true
if this is a square matrix.
Returns true
if this is a unitary matrix Raises an error if matrix is not square.
Returns the rank of the matrix. Beware that using Float
values can yield erroneous results because of their lack of precision. Consider using exact types like Rational
or BigDecimal
instead.
Matrix[[7,6], [3,9]].rank => 2
deprecated; use Matrix#rank
Returns the trace (sum of diagonal elements) of the matrix.
Matrix[[7,6], [3,9]].trace => 16
Returns the transpose of the matrix.
Matrix[[1,2], [3,4], [5,6]] => 1 2 3 4 5 6 Matrix[[1,2], [3,4], [5,6]].transpose => 1 3 5 2 4 6
Returns the imaginary part of the matrix.
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] => 1+2i i 0 1 2 3 Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary => 2i i 0 0 0 0