Skip to content

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

instance method

IO::Buffer#hexdump

() -> ::String
hexdump([offset, [length, [width]]]) → string

Returns a human-readable string representation of the buffer. The exact format is subject to change.

Example
buffer = IO::Buffer.for("Hello World")
puts buffer.hexdump
# 0x00000000  48 65 6c 6c 6f 20 57 6f 72 6c 64                Hello World

As buffers are usually fairly big, you may want to limit the output by specifying the offset and length:

Example
puts buffer.hexdump(6, 5)
# 0x00000006  57 6f 72 6c 64                                  World