Specifies a File
object input
that is input stream for Readline.readline
method.
Open the syslog facility. Raises a runtime exception if it is already open.
Can be called with or without a code block. If called with a block, the Syslog
object created is passed to the block.
If the syslog is already open, raises a RuntimeError
.
ident
is a String
which identifies the calling program.
options
is the logical OR of any of the following:
If there is an error while sending to the system logger, write directly to the console instead.
Open the connection now, rather than waiting for the first message to be written.
Don’t wait for any child processes created while logging messages. (Has no effect on Linux.)
Opposite of LOG_NDELAY; wait until a message is sent before opening the connection. (This is the default.)
Print the message to stderr as well as sending it to syslog. (Not in POSIX.1-2001.)
Include the current process ID with each message.
facility
describes the type of program opening the syslog, and is the logical OR of any of the following which are defined for the host OS:
Security or authorization. Deprecated, use LOG_AUTHPRIV instead.
Security or authorization messages which should be kept private.
System console message.
System task scheduler (cron or at).
A system daemon which has no facility value of its own.
An FTP server.
A kernel message (not sendable by user processes, so not of much use to Ruby, but listed here for completeness).
Line printer subsystem.
Mail delivery or transport subsystem.
Usenet news system.
Network Time
Protocol server.
General security message.
Messages generated internally by syslog.
Generic user-level message.
UUCP subsystem.
Locally-defined facilities.
Example:
Syslog.open("webrick", Syslog::LOG_PID, Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3)
Returns true if the syslog is open.
Closes the syslog facility. Raises a runtime exception if it is not open.
Calculates Adler-32 checksum for string
, and returns updated value of adler
. If string
is omitted, it returns the Adler-32 initial value. If adler
is omitted, it assumes that the initial value is given to adler
.
Example usage:
require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145
Returns true
if the named file exists and has a zero size.
file_name can be an IO
object.
Returns true
if the named file exists and has a zero size.
file_name can be an IO
object.
Returns true
if the named file is a character device.
file_name can be an IO
object.
Returns true
if the named file has the setuid bit set.
file_name can be an IO
object.
Returns true
if the named file has the setgid bit set.
file_name can be an IO
object.
Returns true
if the named file has the sticky bit set.
file_name can be an IO
object.
Returns true
if the named files are identical.
file_1 and file_2 can be an IO
object.
open("a", "w") {} p File.identical?("a", "a") #=> true p File.identical?("a", "./a") #=> true File.link("a", "b") p File.identical?("a", "b") #=> true File.symlink("a", "c") p File.identical?("a", "c") #=> true open("d", "w") {} p File.identical?("a", "d") #=> false
Initiates garbage collection, unless manually disabled.
This method is defined with keyword arguments that default to true:
def GC.start(full_mark: true, immediate_sweep: true); end
Use full_mark: false to perform a minor GC
. Use immediate_sweep: false to defer sweeping (use lazy sweep).
Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.
Invokes the block with a Benchmark::Report object, which may be used to collect and report on the results of individual benchmark tests. Reserves label_width
leading spaces for labels on each line. Prints caption
at the top of the report, and uses format
to format each line. Returns an array of Benchmark::Tms
objects.
If the block returns an array of Benchmark::Tms
objects, these will be used to format additional lines of output. If labels
parameter are given, these are used to label these extra lines.
Note: Other methods provide a simpler interface to this one, and are suitable for nearly all benchmarking requirements. See the examples in Benchmark
, and the bm
and bmbm
methods.
Example:
require 'benchmark' include Benchmark # we need the CAPTION and FORMAT constants n = 5000000 Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| tf = x.report("for:") { for i in 1..n; a = "1"; end } tt = x.report("times:") { n.times do ; a = "1"; end } tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } [tf+tt+tu, (tf+tt+tu)/3] end
Generates:
user system total real for: 0.970000 0.000000 0.970000 ( 0.970493) times: 0.990000 0.000000 0.990000 ( 0.989542) upto: 0.970000 0.000000 0.970000 ( 0.972854) >total: 2.930000 0.000000 2.930000 ( 2.932889) >avg: 0.976667 0.000000 0.976667 ( 0.977630)
Returns the elapsed real time used to execute the given block.
Invokes the block with a Benchmark::Report object, which may be used to collect and report on the results of individual benchmark tests. Reserves label_width
leading spaces for labels on each line. Prints caption
at the top of the report, and uses format
to format each line. Returns an array of Benchmark::Tms
objects.
If the block returns an array of Benchmark::Tms
objects, these will be used to format additional lines of output. If labels
parameter are given, these are used to label these extra lines.
Note: Other methods provide a simpler interface to this one, and are suitable for nearly all benchmarking requirements. See the examples in Benchmark
, and the bm
and bmbm
methods.
Example:
require 'benchmark' include Benchmark # we need the CAPTION and FORMAT constants n = 5000000 Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| tf = x.report("for:") { for i in 1..n; a = "1"; end } tt = x.report("times:") { n.times do ; a = "1"; end } tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } [tf+tt+tu, (tf+tt+tu)/3] end
Generates:
user system total real for: 0.970000 0.000000 0.970000 ( 0.970493) times: 0.990000 0.000000 0.990000 ( 0.989542) upto: 0.970000 0.000000 0.970000 ( 0.972854) >total: 2.930000 0.000000 2.930000 ( 2.932889) >avg: 0.976667 0.000000 0.976667 ( 0.977630)
Returns the elapsed real time used to execute the given block.
Retrieve the PathSupport
object that RubyGems uses to lookup files.
Initialize the filesystem paths to use from env
. env
is a hash-like object (typically ENV
) that is queried for ‘GEM_HOME’, ‘GEM_PATH’, and ‘GEM_SPEC_CACHE’ Keys for the env
hash should be Strings, and values of the hash should be Strings or nil
.
Prints the amount of time the supplied block takes to run using the debug UI output.
Is uri
the URI
for the current local server?