ENV.has_key?
, ENV.member?
, and ENV.key?
are aliases for ENV.include?
.
Returns true
if there is an environment variable with the given name
:
ENV.replace('foo' => '0', 'bar' => '1') ENV.include?('foo') # => true
Returns false
if name
is a valid String
and there is no such environment variable:
ENV.include?('baz') # => false
Returns false
if name
is the empty String
or is a String
containing character '='
:
ENV.include?('') # => false ENV.include?('=') # => false
Raises an exception if name
is a String
containing the NUL character "\0"
:
ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
Raises an exception if name
has an encoding that is not ASCII-compatible:
ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE)) # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
Raises an exception if name
is not a String:
ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
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.
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
containing anything CSV::new()
understands.
Sets optional filename and line number that will be used in ERB
code evaluation and error reporting. See also filename=
and lineno=
erb = ERB.new('<%= some_x %>') erb.render # undefined local variable or method `some_x' # from (erb):1 erb.location = ['file.erb', 3] # All subsequent error reporting would use new location erb.render # undefined local variable or method `some_x' # from file.erb:4
Returns true if the ipaddr is a private address. IPv4 addresses in 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC 1918 and IPv6 Unique Local Addresses in fc00::/7 as defined in RFC 4193 are considered private.
Returns true
iff the current severity level allows for the printing of FATAL
messages.
Sets the severity to FATAL.
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
Returns true
if this is a diagonal 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 this is a symmetric matrix. Raises an error if matrix is not square.
Returns true
if this is an antisymmetric matrix. Raises an error if matrix is not square.
Returns the determinant 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]].determinant => 45
deprecated; use Matrix#determinant
Returns the conjugate 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]].conjugate => 1-2i -i 0 1 2 3
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
Creates a vector from an Array
. The optional second argument specifies whether the array itself or a copy is used internally.