Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

IO::Buffer#each_byte

each_byte([offset, [count]]) {|byte| ...} → self
each_byte([offset, [count]]) → enumerator

Iterates over the buffer, yielding each byte starting from offset.

If count is given, only count bytes will be yielded.

Example
IO::Buffer.for("Hello World").each_byte(2, 2) do |offset, byte|
  puts "#{offset}: #{byte}"
end
# 2: 108
# 3: 108
See also #each #empty? #copy #get_string also in 4.0 · 3.4 · 3.3 · 3.2