See Zlib::GzipReader
documentation for a description. However, note that this method can return nil
even if eof?
returns false, unlike the behavior of File#gets
.
Returns the number of native file system blocks allocated for this file, or nil
if the operating system doesn’t support this feature.
File.stat("testfile").blocks #=> 2
Returns true
if stat is a zero-length file; false
otherwise.
File.stat("testfile").zero? #=> false
Returns true
if the file is a block device, false
if it isn’t or if the operating system doesn’t support this feature.
File.stat("testfile").blockdev? #=> false File.stat("/dev/hda1").blockdev? #=> true
Returns true
if key
is registered
Transfers ownership to a new buffer, deallocating the current one.
Example:
buffer = IO::Buffer.new('test') other = buffer.transfer other # => # #<IO::Buffer 0x00007f136a15f7b0+4 SLICE> # 0x00000000 74 65 73 74 test buffer # => # #<IO::Buffer 0x0000000000000000+0 NULL> buffer.null? # => true
The buffer is external if it references the memory which is not allocated or mapped by the buffer itself.
A buffer created using ::for
has an external reference to the string’s memory.
External buffer can’t be resized.
If the buffer is internal, meaning it references memory allocated by the buffer itself.
An internal buffer is not associated with any external memory (e.g. string) or file mapping.
Internal buffers are created using ::new
and is the default when the requested size is less than the IO::Buffer::PAGE_SIZE
and it was not requested to be mapped on creation.
Internal buffers can be resized, and such an operation will typically invalidate all slices, but not always.
If the buffer is locked, meaning it is inside locked
block execution. Locked buffer can’t be resized or freed, and another lock can’t be acquired on it.
Locking is not thread safe, but is a semantic used to ensure buffers don’t move while being used by a system call.
Example:
buffer.locked do buffer.write(io) # theoretical system call interface end
Allows to process a buffer in exclusive way, for concurrency-safety. While the block is performed, the buffer is considered locked, and no other code can enter the lock. Also, locked buffer can’t be changed with resize
or free
.
The following operations acquire a lock: resize
, free
.
Locking is not thread safe. It is designed as a safety net around non-blocking system calls. You can only share a buffer between threads with appropriate synchronisation techniques.
Example:
buffer = IO::Buffer.new(4) buffer.locked? #=> false Fiber.schedule do buffer.locked do buffer.write(io) # theoretical system call interface end end Fiber.schedule do # in `locked': Buffer already locked! (IO::Buffer::LockedError) buffer.locked do buffer.set_string("test", 0) end end
Returns a new Tms
object obtained by memberwise operation op
of the individual times for this Tms
object with those of the other Tms
object (x
).
op
can be a mathematical operation such as +
, -
, *
, /
Store session data on the server and close the session storage. For some session storage types, this is a no-op.
Returns the headers for this row:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) row = table.first row.headers # => ["Name", "Value"]
Returns a new Array containing the String headers for the table.
If the table is not empty, returns the headers from the first row:
rows = [ CSV::Row.new(['Foo', 'Bar'], []), CSV::Row.new(['FOO', 'BAR'], []), CSV::Row.new(['foo', 'bar'], []), ] table = CSV::Table.new(rows) table.headers # => ["Foo", "Bar"] table.delete(0) table.headers # => ["FOO", "BAR"] table.delete(0) table.headers # => ["foo", "bar"]
If the table is empty, returns a copy of the headers in the table itself:
table.delete(0) table.headers # => ["Foo", "Bar"]
Attempt to load the wrapped marshalled object again.
If the class of the object is now known locally, the object will be unmarshalled and returned. Otherwise, a new but identical DRbUnknown
object will be returned.
Unmarshall a marshalled DRbObject
.
If the referenced object is located within the local server, then the object itself is returned. Otherwise, a new DRbObject
is created to act as a stub for the remote referenced object.
Set
the default value of the :verbose option.
See new(). The initial default value is false.
Get the default value of the :verbose option.
Set
whether to operate in verbose mode.
In verbose mode, failed calls are logged to stdout.
Get whether the server is in verbose mode.
In verbose mode, failed calls are logged to stdout.
Is uri
the URI
for this server?