instance method
IO::Buffer#write
(untyped, untyped) -> untyped
write(io, [length, [offset]]) → written length or -errno
io_buffer.c
View on GitHub ↗
static VALUE
io_buffer_write(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, 3);
VALUE io = argv[0];
size_t length, offset;
io_buffer_extract_length_offset(self, argc-1, argv+1, &length, &offset);
return rb_io_buffer_write(self, io, length, offset);
}
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.
Example
out = File.open('output.txt', 'wb') IO::Buffer.for('1234567').write(out, 3)
This leads to 123 being written into output.txt