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 the full path name of the temporary file. This will be nil if unlink
has been called.
Creates a temporary file as a usual File
object (not a Tempfile
). It does not use finalizer and delegation, which makes it more efficient and reliable.
If no block is given, this is similar to Tempfile.new
except creating File
instead of Tempfile
. In that case, 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, releasing all resources that the block created. The call returns the value of the block.
In any case, all arguments (basename
, tmpdir
, mode
, and **options
) will be treated the same as for Tempfile.new
.
Tempfile.create('foo', '/home/temp') do |f| # ... do something with f ... end
returns main ractor
Returns the main thread.
Terminates thr
and schedules another thread to be run, returning the terminated 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.
Sets the maximum size of the queue to the given number
.
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.
Path of the file being run
Create a new BigDecimal
object.
The initial value, as an Integer
, a Float
, a Rational
, a BigDecimal
, or a String
.
If it is a String
, spaces are ignored and unrecognized characters terminate the value.
The number of significant digits, as an Integer
. If omitted or 0, the number of significant digits is determined from the initial value.
The actual number of significant digits used in computation is usually larger than the specified number.
Whether an exception should be raised on invalid arguments. true
by default, if passed false
, just returns nil
for invalid.
TypeError
If the initial
type is neither Integer
, Float
, Rational
, nor BigDecimal
, this exception is raised.
TypeError
If the digits
is not an Integer
, this exception is raised.
ArgumentError
If initial
is a Float
, and the digits
is larger than Float::DIG + 1, this exception is raised.
ArgumentError
If the initial
is a Float
or Rational
, and the digits
value is omitted, this exception is raised.
Creates a new Pathname
object from the given string, path
, and returns pathname object.
In order to use this constructor, you must first require the Pathname
standard library extension.
require 'pathname' Pathname("/home/zzak") #=> #<Pathname:/home/zzak>
See also Pathname::new
for more information.
Equivalent to:
$stdout.putc(int)
Refer to the documentation for IO#putc
for important information regarding multi-byte characters.
Returns arg converted to a float. Numeric
types are converted directly, and with exception to String
and nil
the rest are converted using arg.to_f
. Converting a String
with invalid characters will result in a ArgumentError
. Converting nil
generates a TypeError
. Exceptions can be suppressed by passing exception: false
.
Float(1) #=> 1.0 Float("123.456") #=> 123.456 Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" Float(nil) #=> TypeError: can't convert nil into Float Float("123.0_badstring", exception: false) #=> nil
Returns x/y
or arg
as a Rational
.
Rational(2, 3) #=> (2/3) Rational(5) #=> (5/1) Rational(0.5) #=> (1/2) Rational(0.3) #=> (5404319552844595/18014398509481984) Rational("2/3") #=> (2/3) Rational("0.3") #=> (3/10) Rational("10 cents") #=> ArgumentError Rational(nil) #=> TypeError Rational(1, nil) #=> TypeError Rational("10 cents", exception: false) #=> nil
Syntax of the string form:
string form = extra spaces , rational , extra spaces ; rational = [ sign ] , unsigned rational ; unsigned rational = numerator | numerator , "/" , denominator ; numerator = integer part | fractional part | integer part , fractional part ; denominator = digits ; integer part = digits ; fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; sign = "-" | "+" ; digits = digit , { digit | "_" , digit } ; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; extra spaces = ? \s* ? ;
See also String#to_r
.