Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

IO::Buffer#write

write(io, length, [offset]) → written length or -errno

Writes length bytes from buffer into io, starting at offset in the buffer. If an error occurs, return -errno.

If offset is not given, the bytes are taken from 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

See also #values #xor! #valid? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1