Resets the position of the file pointer to the point created the GzipReader
object. The associated IO
object needs to respond to the seek
method.
See Zlib::GzipReader
documentation for a description.
See Zlib::GzipReader
documentation for a description.
Returns the number of hard links to stat.
File.stat("testfile").nlink #=> 1 File.link("testfile", "testfile.bak") #=> 0 File.stat("testfile").nlink #=> 2
Produce a nicely formatted description of stat.
File.stat("/etc/passwd").inspect #=> "#<File::Stat dev=0xe000005, ino=1078078, mode=0100644, # nlink=1, uid=0, gid=0, rdev=0x0, size=1374, blksize=4096, # blocks=8, atime=Wed Dec 10 10:16:12 CST 2003, # mtime=Fri Sep 12 15:41:41 CDT 2003, # ctime=Mon Oct 27 11:20:27 CST 2003, # birthtime=Mon Aug 04 08:13:49 CDT 2003>"
Returns true
if stat is a symbolic link, false
if it isn’t or if the operating system doesn’t support this feature. As File::stat
automatically follows symbolic links, symlink?
will always be false
for an object returned by File::stat
.
File.symlink("testfile", "alink") #=> 0 File.stat("alink").symlink? #=> false File.lstat("alink").symlink? #=> true
Returns true
if key
is registered
Create an IO::Buffer
for reading from file
by memory-mapping the file. file_io
should be a File
instance, opened for reading.
Optional size
and offset
of mapping can be specified.
By default, the buffer would be immutable (read only); to create a writable mapping, you need to open a file in read-write mode, and explicitly pass flags
argument without IO::Buffer::IMMUTABLE.
Example:
File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY> buffer.readonly? # => true buffer.get_string # => "test" buffer.set_string('b', 0) # `set_string': Buffer is not writable! (IO::Buffer::AccessError) # create read/write mapping: length 4 bytes, offset 0, flags 0 buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0) buffer.set_string('b', 0) # => 1 # Check it File.read('test.txt') # => "best"
Note that some operating systems may not have cache coherency between mapped buffers and file reads.
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 mapped, meaning it references memory mapped by the buffer.
Mapped buffers are either anonymous, if created by ::new
with the IO::Buffer::MAPPED
flag or if the size was at least IO::Buffer::PAGE_SIZE
, or backed by a file if created with ::map
.
Mapped buffers can usually be resized, and such an operation will typically invalidate all slices, but not always.
Returns a human-readable string representation of this instruction sequence, including the label
and path
.
Returns the contents of this Tms
object as a formatted string, according to a format
string like that passed to Kernel.format
. In addition, format
accepts the following extensions:
%u
Replaced by the user CPU time, as reported by Tms#utime
.
%y
Replaced by the system CPU time, as reported by stime
(Mnemonic: y of “s*y*stem”)
%U
Replaced by the children’s user CPU time, as reported by Tms#cutime
%Y
Replaced by the children’s system CPU time, as reported by Tms#cstime
%t
Replaced by the total CPU time, as reported by Tms#total
%r
Replaced by the elapsed real time, as reported by Tms#real
%n
Replaced by the label string, as reported by Tms#label
(Mnemonic: n of “*n*ame”)
If format
is not given, FORMAT
is used as default value, detailing the user, system and real elapsed time.
A summary of cookie string.
Returns the index for the given header, if it exists; otherwise returns nil
.
With the single argument header
, returns the index of the first-found field with the given header
:
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.index('Name') # => 0 row.index('NAME') # => nil
With arguments header
and offset
, returns the index of the first-found field with given header
, but ignoring the first offset
fields:
row.index('Name', 1) # => 1 row.index('Name', 3) # => nil
Returns an ASCII-compatible String showing:
Class
CSV::Row.
Header-value pairs.
Example:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) row = table[0] row.inspect # => "#<CSV::Row \"Name\":\"foo\" \"Value\":\"0\">"
Returns a US-ASCII
-encoded String showing table:
Class: CSV::Table
.
Access mode: :row
, :col
, or :col_or_row
.
Size: Row
count, including the header row.
Example:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) table.inspect # => "#<CSV::Table mode:col_or_row row_count:4>\nName,Value\nfoo,0\nbar,1\nbaz,2\n"
Winds back to the beginning
Matches addr
against this entry.