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.new("42") b = BigDecimal.new("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=
Puts ARGF
into binary mode. Once a stream is in binary mode, it cannot be reset to non-binary mode. This option has the following effects:
Newline conversion is disabled.
Encoding
conversion is disabled.
Content is treated as ASCII-8BIT.
Returns true if ARGF
is being read in binary mode; false otherwise. To enable binary mode use ARGF.binmode
.
For example:
ARGF.binmode? #=> false ARGF.binmode ARGF.binmode? #=> true
See Numeric#divmod
.
Returns a BubbleBabble encoded version of a given string.
Changes permission bits on the named files (in list
) to the bit pattern represented by mode
.
mode
is the symbolic and absolute mode can be used.
Absolute mode is
FileUtils.chmod 0755, 'somecommand' FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb) FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
Symbolic mode is
FileUtils.chmod "u=wrx,go=rx", 'somecommand' FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb) FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :verbose => true
is user, group, other mask.
is user’s mask.
is group’s mask.
is other’s mask.
is write permission.
is read permission.
is execute permission.
is execute permission for directories only, must be used in conjunction with “+”
is uid, gid.
is sticky bit.
is added to a class given the specified mode.
Is removed from a given class given mode.
Is the exact nature of the class will be given a specified mode.
Changes permission bits on the named files (in list
) to the bit pattern represented by mode
.
mode
is the symbolic and absolute mode can be used.
Absolute mode is
FileUtils.chmod 0755, 'somecommand' FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb) FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
Symbolic mode is
FileUtils.chmod "u=wrx,go=rx", 'somecommand' FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb) FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :verbose => true
is user, group, other mask.
is user’s mask.
is group’s mask.
is other’s mask.
is write permission.
is read permission.
is execute permission.
is execute permission for directories only, must be used in conjunction with “+”
is uid, gid.
is sticky bit.
is added to a class given the specified mode.
Is removed from a given class given mode.
Is the exact nature of the class will be given a specified mode.
Changes permission bits on the named files (in list
) to the bit pattern represented by mode
.
FileUtils.chmod_R 0700, "/tmp/app.#{$$}" FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
Changes permission bits on the named files (in list
) to the bit pattern represented by mode
.
FileUtils.chmod_R 0700, "/tmp/app.#{$$}" FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
Sets the preset dictionary and returns string
. This method is available just only after Zlib::Deflate.new
or Zlib::ZStream#reset
method was called. See zlib.h for details.
Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn’t match the expected one (incorrect adler32 value)
Provide the inflate stream with a dictionary that may be required in the future. Multiple dictionaries may be provided. The inflate stream will automatically choose the correct user-provided dictionary based on the stream’s required dictionary.
Sets the preset dictionary and returns string
. This method is available just only after a Zlib::NeedDict
exception was raised. See zlib.h for details.