List of options that will be supplied to RDoc
Returns the execution stack for the target thread—an array containing backtrace location objects.
See Thread::Backtrace::Location
for more information.
This method behaves similarly to Kernel#caller_locations
except it applies to a specific thread.
Returns the Ruby source filename and line number containing this proc or nil
if this proc was not defined in Ruby (i.e. native).
Returns the Ruby source filename and line number containing this method or nil if this method was not defined in Ruby (i.e. native).
Returns the Ruby source filename and line number containing this method or nil if this method was not defined in Ruby (i.e. native).
Value from exception raised on the :raise
event
Returns the original line from source for from the given object
.
See ::trace_object_allocations
for more information and examples.
Returns the number of malloc() allocations.
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
def_exception
(n, m, s)
n: exception_name m: message_form s: superclass(default: StandardError) define exception named ``c'' with message m.
Returns true if the method mid
have an option opt
.
p FileUtils.have_option?(:cp, :noop) #=> true p FileUtils.have_option?(:rm, :force) #=> true p FileUtils.have_option?(:rm, :preserve) #=> false
Returns an Array of option names of the method mid
.
p FileUtils.options_of(:rm) #=> ["noop", "verbose", "force"]
Returns whether or not the function func
can be found in the common header files, or within any headers
that you provide. If found, a macro is passed as a preprocessor constant to the compiler using the function name, in uppercase, prepended with HAVE_
.
To check functions in an additional library, you need to check that library first using have_library()
. The func
shall be either mere function name or function name with arguments.
For example, if have_func('foo')
returned true
, then the HAVE_FOO
preprocessor macro would be passed to the compiler.
Returns an array containing the quotient and modulus obtained by dividing num
by numeric
.
If q, r = x.divmod(y)
, then
q = floor(x/y) x = q*y + r
The quotient is rounded toward negative infinity, as shown in the following table:
a | b | a.divmod(b) | a/b | a.modulo(b) | a.remainder(b) ------+-----+---------------+---------+-------------+--------------- 13 | 4 | 3, 1 | 3 | 1 | 1 ------+-----+---------------+---------+-------------+--------------- 13 | -4 | -4, -3 | -4 | -3 | 1 ------+-----+---------------+---------+-------------+--------------- -13 | 4 | -4, 3 | -4 | 3 | -1 ------+-----+---------------+---------+-------------+--------------- -13 | -4 | 3, -1 | 3 | -1 | -1 ------+-----+---------------+---------+-------------+--------------- 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5 ------+-----+---------------+---------+-------------+--------------- 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5 ------+-----+---------------+---------+-------------+--------------- -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5 ------+-----+---------------+---------+-------------+--------------- -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5
Examples
11.divmod(3) #=> [3, 2] 11.divmod(-3) #=> [-4, -1] 11.divmod(3.5) #=> [3, 0.5] (-11).divmod(3.5) #=> [-4, 3.0] 11.5.divmod(3.5) #=> [3, 1.0]
Changes permission bits on the named file(s) to the bit pattern represented by mode_int. Actual effects are operating system dependent (see the beginning of this section). On Unix systems, see chmod(2)
for details. Returns the number of files processed.
File.chmod(0644, "testfile", "out") #=> 2
Equivalent to File::chmod
, but does not follow symbolic links (so it will change the permissions associated with the link, not the file referenced by the link). Often not available.
Changes permission bits on file to the bit pattern represented by mode_int. Actual effects are platform dependent; on Unix systems, see chmod(2)
for details. Follows symbolic links. Also see File#lchmod
.
f = File.new("out", "w"); f.chmod(0644) #=> 0
Controls handling of arithmetic exceptions and rounding. If no value is supplied, the current value is returned.
Six values of the mode parameter control the handling of arithmetic exceptions:
BigDecimal::EXCEPTION_NaN
BigDecimal::EXCEPTION_INFINITY
BigDecimal::EXCEPTION_UNDERFLOW
BigDecimal::EXCEPTION_OVERFLOW
BigDecimal::EXCEPTION_ZERODIVIDE
BigDecimal::EXCEPTION_ALL
For each mode parameter above, if the value set is false, computation continues after an arithmetic exception of the appropriate type. When computation continues, results are as follows:
EXCEPTION_NaN
NaN
EXCEPTION_INFINITY
+Infinity or -Infinity
EXCEPTION_UNDERFLOW
0
EXCEPTION_OVERFLOW
+Infinity or -Infinity
EXCEPTION_ZERODIVIDE
+Infinity or -Infinity
One value of the mode parameter controls the rounding of numeric values: BigDecimal::ROUND_MODE
. The values it can take are:
ROUND_UP
, :up
round away from zero
ROUND_DOWN
, :down, :truncate
round towards zero (truncate)
ROUND_HALF_UP
, :half_up, :default
round towards the nearest neighbor, unless both neighbors are equidistant, in which case round away from zero. (default)
ROUND_HALF_DOWN
, :half_down
round towards the nearest neighbor, unless both neighbors are equidistant, in which case round towards zero.
ROUND_HALF_EVEN
, :half_even, :banker
round towards the nearest neighbor, unless both neighbors are equidistant, in which case round towards the even neighbor (Banker’s rounding)
ROUND_CEILING
, :ceiling, :ceil
round towards positive infinity (ceil)
ROUND_FLOOR
, :floor
round towards negative infinity (floor)
Divides by the specified value, and returns the quotient and modulus as BigDecimal
numbers. The quotient is rounded towards negative infinity.
For example:
require 'bigdecimal' a = BigDecimal("42") b = BigDecimal("9") q, m = a.divmod(b) c = q * b + m a == c #=> true
The quotient q is (a/b).floor, and the modulus is the amount that must be added to q * b to get a.
Puts ios into binary mode. Once a stream is in binary mode, it cannot be reset to nonbinary mode.
newline conversion disabled
encoding conversion disabled
content is treated as ASCII-8BIT
Returns true
if ios is binmode.
Turns the database’s fast mode on or off. If fast mode is turned on, gdbm does not wait for writes to be flushed to the disk before continuing.
This option is obsolete for gdbm >= 1.8 since fast mode is turned on by default. See also: syncmode=