Print an argument or list of arguments to the default output stream
cgi = CGI.new cgi.print # default: cgi.print == $DEFAULT_OUTPUT.print
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.
Returns the IO
used as stdout. Defaults to STDOUT
Sets the IO
used as stdout. Defaults to STDOUT
Set
the handling of the ordering of options and arguments. A RuntimeError
is raised if option processing has already started.
The supplied value must be a member of GetoptLong::ORDERINGS
. It alters the processing of options as follows:
REQUIRE_ORDER :
Options are required to occur before non-options.
Processing of options ends as soon as a word is encountered that has not been preceded by an appropriate option flag.
For example, if -a and -b are options which do not take arguments, parsing command line arguments of ‘-a one -b two’ would result in ‘one’, ‘-b’, ‘two’ being left in ARGV, and only (‘-a’, ”) being processed as an option/arg pair.
This is the default ordering, if the environment variable POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)
PERMUTE :
Options can occur anywhere in the command line parsed. This is the default behavior.
Every sequence of words which can be interpreted as an option (with or without argument) is treated as an option; non-option words are skipped.
For example, if -a does not require an argument and -b optionally takes an argument, parsing ‘-a one -b two three’ would result in (‘-a’,”) and (‘-b’, ‘two’) being processed as option/arg pairs, and ‘one’,‘three’ being left in ARGV.
If the ordering is set to PERMUTE but the environment variable POSIXLY_CORRECT is set, REQUIRE_ORDER is used instead. This is for compatibility with GNU getopt_long.
RETURN_IN_ORDER :
All words on the command line are processed as options. Words not preceded by a short or long option flag are passed as arguments with an option of ” (empty string).
For example, if -a requires an argument but -b does not, a command line of ‘-a one -b two three’ would result in option/arg pairs of (‘-a’, ‘one’) (‘-b’, ”), (”, ‘two’), (”, ‘three’) being processed.
Returns true if the ipaddr is an IPv4 address.
Returns true if the ipaddr is an IPv6 address.
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 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 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 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]]
Returns the Eigensystem of the matrix; see EigenvalueDecomposition
.
m = Matrix[[1, 2], [3, 4]] v, d, v_inv = m.eigensystem d.diagonal? # => true v.inv == v_inv # => true (v * d * v_inv).round(5) == m # => true
Puts option summary into to
and returns to
. Yields each line if a block is given.
to
Output destination, which must have method <<. Defaults to [].
width
Width of left side, defaults to @summary_width.
max
Maximum length allowed for left side, defaults to width
- 1.
indent
Indentation, defaults to @summary_indent.
Puts option summary into to
and returns to
. Yields each line if a block is given.
to
Output destination, which must have method <<. Defaults to [].
width
Width of left side, defaults to @summary_width.
max
Maximum length allowed for left side, defaults to width
- 1.
indent
Indentation, defaults to @summary_indent.
Increases left margin after newline with indent
for line breaks added in the block.
Returns true if value
is a prime number, else returns false.
value
an arbitrary integer to be checked.
generator
optional. A pseudo-prime generator.
Opens a new transaction for the data store. Code executed inside a block passed to this method may read and write data to and from the data store file.
At the end of the block, changes are committed to the data store automatically. You may exit the transaction early with a call to either PStore#commit
or PStore#abort
. See those methods for details about how changes are handled. Raising an uncaught Exception
in the block is equivalent to calling PStore#abort
.
If read_only is set to true
, you will only be allowed to read from the data store during the transaction and any attempts to change the data will raise a PStore::Error
.
Note that PStore
does not support nested transactions.
Returns true if self
is a prime number, else returns false.
As int
is already an Integer
, all these methods simply return the receiver.
Deletes every element that appears in the given enumerable object and returns self.
Basically the same as ::new
. However, if class Thread
is subclassed, then calling start
in that subclass will not invoke the subclass’s initialize
method.
Stops execution of the current thread, putting it into a “sleep” state, and schedules execution of another thread.
a = Thread.new { print "a"; Thread.stop; print "c" } sleep 0.1 while a.status!='sleep' print "b" a.run a.join #=> "abc"