Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

IO::Buffer#get_string

(?::Integer offset, ?::Integer length, ?::Encoding encoding) -> ::String
get_string([offset, [length, [encoding]]]) → string

Read a chunk or all of the buffer into a string, in the specified encoding. If no encoding is provided Encoding::BINARY is used.

Example
buffer = IO::Buffer.for('test')
buffer.get_string
# => "test"
buffer.get_string(2)
# => "st"
buffer.get_string(2, 1)
# => "s"
See also #free #get_value #external? #get_values also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1