Update IO::Buffer documentation. (#11737)

Update documentation.
This commit is contained in:
Samuel Williams 2024-10-03 15:33:48 +13:00 committed by GitHub
parent e5c26b0f32
commit 75c4ac3395
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-10-03 02:34:06 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>

View File

@ -1568,7 +1568,7 @@ rb_io_buffer_slice(struct rb_io_buffer *buffer, VALUE self, size_t offset, size_
* buffer's bounds. * buffer's bounds.
* *
* string = 'test' * string = 'test'
* buffer = IO::Buffer.for(string) * buffer = IO::Buffer.for(string).dup
* *
* slice = buffer.slice * slice = buffer.slice
* # => * # =>
@ -1595,12 +1595,8 @@ rb_io_buffer_slice(struct rb_io_buffer *buffer, VALUE self, size_t offset, size_
* # it is also visible at position 1 of the original buffer * # it is also visible at position 1 of the original buffer
* buffer * buffer
* # => * # =>
* # #<IO::Buffer 0x00007fc3d31e2d80+4 SLICE> * # #<IO::Buffer 0x00007fc3d31e2d80+4 INTERNAL>
* # 0x00000000 74 6f 73 74 tost * # 0x00000000 74 6f 73 74 tost
*
* # ...and original string
* string
* # => tost
*/ */
static VALUE static VALUE
io_buffer_slice(int argc, VALUE *argv, VALUE self) io_buffer_slice(int argc, VALUE *argv, VALUE self)
@ -2443,10 +2439,11 @@ rb_io_buffer_initialize_copy(VALUE self, VALUE source)
* *
* #copy can be used to put buffer into strings associated with buffer: * #copy can be used to put buffer into strings associated with buffer:
* *
* string= "data: " * string = "data: "
* # => "data: " * # => "data: "
* buffer = IO::Buffer.for(string) * buffer = IO::Buffer.for(string) do |buffer|
* buffer.copy(IO::Buffer.for("test"), 5) * buffer.copy(IO::Buffer.for("test"), 5)
* end
* # => 4 * # => 4
* string * string
* # => "data:test" * # => "data:test"
@ -2590,29 +2587,29 @@ rb_io_buffer_clear(VALUE self, uint8_t value, size_t offset, size_t length)
* Fill buffer with +value+, starting with +offset+ and going for +length+ * Fill buffer with +value+, starting with +offset+ and going for +length+
* bytes. * bytes.
* *
* buffer = IO::Buffer.for('test') * buffer = IO::Buffer.for('test').dup
* # => * # =>
* # <IO::Buffer 0x00007fca40087c38+4 SLICE> * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 74 65 73 74 test * # 0x00000000 74 65 73 74 test
* *
* buffer.clear * buffer.clear
* # => * # =>
* # <IO::Buffer 0x00007fca40087c38+4 SLICE> * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 00 00 00 00 .... * # 0x00000000 00 00 00 00 ....
* *
* buf.clear(1) # fill with 1 * buf.clear(1) # fill with 1
* # => * # =>
* # <IO::Buffer 0x00007fca40087c38+4 SLICE> * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 01 01 01 01 .... * # 0x00000000 01 01 01 01 ....
* *
* buffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes * buffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes
* # => * # =>
* # <IO::Buffer 0x00007fca40087c38+4 SLICE> * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 01 02 02 01 .... * # 0x00000000 01 02 02 01 ....
* *
* buffer.clear(2, 1) # fill with 2, starting from offset 1 * buffer.clear(2, 1) # fill with 2, starting from offset 1
* # => * # =>
* # <IO::Buffer 0x00007fca40087c38+4 SLICE> * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 01 02 02 02 .... * # 0x00000000 01 02 02 02 ....
*/ */
static VALUE static VALUE