See Zlib::GzipReader
documentation for a description.
See Zlib::GzipReader
documentation for a description.
See Zlib::GzipReader
documentation for a description.
Returns the last access time for this file as an object of class Time
.
File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
Returns true
if the file is a character device, false
if it isn’t or if the operating system doesn’t support this feature.
File.stat("/dev/tty").chardev? #=> true
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.
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 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.
If the buffer is private, meaning modifications to the buffer will not be replicated to the underlying file mapping.
# Create a test file: File.write('test.txt', 'test') # Create a private mapping from the given file. Note that the file here # is opened in read-only mode, but it doesn't matter due to the private # mapping: buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::PRIVATE) # => #<IO::Buffer 0x00007fce63f11000+4 MAPPED PRIVATE> # Write to the buffer (invoking CoW of the underlying file buffer): buffer.set_string('b', 0) # => 1 # The file itself is not modified: File.read('test.txt') # => "test"
Iterates over the buffer, yielding each value
of buffer_type
starting from offset
.
If count
is given, only count
values will be yielded.
IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value| puts "#{offset}: #{value}" end # 2: 108 # 3: 108
Returns the path of this instruction sequence.
<compiled>
if the iseq was evaluated from a string.
For example, using irb:
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> <RubyVM::InstructionSequence:<compiled>@<compiled>> iseq.path #=> "<compiled>"
Using ::compile_file
:
# /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.path #=> /tmp/method.rb
Set
path for which this cookie applies
Set
domain for which this cookie applies
Store session data on the server. For some session storage types, this is a no-op.
Returns the path from an FTP
URI
.
RFC 1738 specifically states that the path for an FTP
URI
does not include the / which separates the URI
path from the URI
host. Example:
ftp://ftp.example.com/pub/ruby
The above URI
indicates that the client should connect to ftp.example.com then cd to pub/ruby from the initial login directory.
If you want to cd to an absolute directory, you must include an escaped / (%2F) in the path. Example:
ftp://ftp.example.com/%2Fpub/ruby
This method will then return “/pub/ruby”.
def operator: () -> String
def operator: () -> String
Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator
.
def operator: () -> String
def operator: () -> String
Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator
.
def operator: () -> String
def operator: () -> String
Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator
.
def operator: () -> String