Same as IO
.
Same as IO
.
Returns true
if stat is writable by the effective user id of this process.
File.stat("testfile").writable? #=> true
Creates a new string of the given length and yields a zero-copy IO::Buffer
instance to the block which uses the string as a source. The block is expected to write to the buffer and the string will be returned.
IO::Buffer.string(4) do |buffer| buffer.set_string("Ruby") end # => "Ruby"
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"
Write at least length
bytes from the buffer starting at offset
, into the io
. If an error occurs, return -errno
.
If length
is not given or nil
, it defaults to the size of the buffer minus the offset, i.e. the entire buffer.
If length
is zero, exactly one write
operation will occur.
If offset
is not given, it defaults to zero, i.e. the beginning of the buffer.
out = File.open('output.txt', 'wb') IO::Buffer.for('1234567').write(out, 3)
This leads to 123
being written into output.txt
Write at least length
bytes from the buffer starting at offset
, into the io
starting at the specified from
position. If an error occurs, return -errno
.
If length
is not given or nil
, it defaults to the size of the buffer minus the offset, i.e. the entire buffer.
If length
is zero, exactly one pwrite
operation will occur.
If offset
is not given, it defaults to zero, i.e. the beginning of the buffer.
If the from
position is beyond the end of the file, the gap will be filled with null (0 value) bytes.
out = File.open('output.txt', File::RDWR) # open for read/write, no truncation IO::Buffer.for('1234567').pwrite(out, 2, 3, 1)
This leads to 234
(3 bytes, starting from position 1) being written into output.txt
, starting from file position 2.
Mirrors the Method#parameters
method.
Returns true if there were errors during parsing and false if there were not.
Look up the typeclass
DNS
resource of name
.
name
must be a Resolv::DNS::Name
or a String
.
typeclass
should be one of the following:
Resolv::DNS::Resource::IN::ANY
Resolv::DNS::Resource::IN::CNAME
Resolv::DNS::Resource::IN::HINFO
Resolv::DNS::Resource::IN::MINFO
Resolv::DNS::Resource::IN::MX
Resolv::DNS::Resource::IN::NS
Resolv::DNS::Resource::IN::PTR
Resolv::DNS::Resource::IN::SOA
Resolv::DNS::Resource::IN::TXT
Returned resource is represented as a Resolv::DNS::Resource
instance, i.e. Resolv::DNS::Resource::IN::A
.
Looks up all typeclass
DNS
resources for name
. See getresource
for argument details.
Override to display a longer description of what this command does.
Writes out this config file, replacing its source.
Changes in rubygems to lazily loading ‘rubygems/command` (in order to lazily load `optparse` as a side effect) affect bundler’s custom installer which uses ‘Gem::Command` without requiring it (up until bundler 2.2.29). This hook is to compensate for that missing require.
TODO: Remove when rubygems no longer supports running on bundler older than 2.2.29.
Verifies that this gem:
Contains a valid gem specification
Contains a contents archive
The contents archive is not corrupt
After verification the gem specification from the gem is available from spec
A detailed description of this gem. See also summary
Writes s to the stream. If the argument is not a String
it will be converted using .to_s
method. Returns the number of bytes written.
Formats and writes to the stream converting parameters under control of the format string.
See Kernel#sprintf
for format string details.