Like Vector#collect2
, but returns a Vector
instead of an Array
.
Returns a new vector with the same direction but with norm 1.
v = Vector[5,8,2].normalize # => Vector[0.5184758473652127, 0.8295613557843402, 0.20739033894608505] v.norm => 1.0
Terminates option parsing. Optional parameter arg
is a string pushed back to be the first non-option argument.
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.
Add separator in summary.
Searches key
in @stack for id
hash and returns or yields the result.
Parses environment variable env
or its uppercase with splitting like a shell.
env
defaults to the basename of the program.
Iterates the given block over all prime numbers.
ubound
Optional. An arbitrary positive number. The upper bound of enumeration. The method enumerates prime numbers infinitely if ubound
is nil.
generator
Optional. An implementation of pseudo-prime generator.
An evaluated value of the given block at the last time. Or an enumerator which is compatible to an Enumerator
if no block given.
Calls block
once for each prime number, passing the prime as a parameter.
ubound
Upper bound of prime numbers. The iterator stops after it yields all prime numbers p <= ubound
.
Returns the path to the data store file.
Returns a new set that is a copy of the set, flattening each containing set recursively.
Equivalent to Set#flatten
, but replaces the receiver with the result in place. Returns nil if no modifications were made.
Calls the given block once for each element in the set, passing the element as parameter. Returns an enumerator if no block is given.
Creates a Shell
object which current directory is set to path
.
If a block is given, it restores the current directory when the block ends.
If called as iterator, it restores the current directory when the block ends.
Returns the full path name of the temporary file. This will be nil if unlink
has been called.
Creates a temporary file as usual File
object (not Tempfile
). It doesn’t use finalizer and delegation.
If no block is given, this is similar to Tempfile.new
except creating File
instead of Tempfile
. The created file is not removed automatically. You should use File.unlink
to remove it.
If a block is given, then a File
object will be constructed, and the block is invoked with the object as the argument. The File
object will be automatically closed and the temporary file is removed after the block terminates. The call returns the value of the block.
In any case, all arguments (basename
, tmpdir
, mode
, and **options
) will be treated as Tempfile.new
.
Tempfile.create('foo', '/home/temp') do |f| # ... do something with f ... end
Path of the file being run
Returns internal information of TracePoint
.
The contents of the returned value are implementation specific. It may be changed in future.
This method is only for debugging TracePoint
itself.
Returns the main thread.
Terminates thr
and schedules another thread to be run.
If this thread is already marked to be killed, exit
returns the Thread
.
If this is the main thread, or the last thread, exits the process.
Returns the status of thr
.
"sleep"
Returned if this thread is sleeping or waiting on I/O
"run"
When this thread is executing
"aborting"
If this thread is aborting
false
When this thread is terminated normally
nil
If terminated with an exception.
a = Thread.new { raise("die now") } b = Thread.new { Thread.stop } c = Thread.new { Thread.exit } d = Thread.new { sleep } d.kill #=> #<Thread:0x401b3678 aborting> a.status #=> nil b.status #=> "sleep" c.status #=> false d.status #=> "aborting" Thread.current.status #=> "run"
Obtains a lock, runs the block, and releases the lock when the block completes. See the example under Mutex
.
Returns the maximum size of the queue.