Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
IO::Buffer.size_of
size_of(buffer_type) → byte size
size_of(array of buffer_type) → byte size
io_buffer.c
View on GitHub ↗
static VALUE
io_buffer_size_of(VALUE klass, VALUE buffer_type)
{
if (RB_TYPE_P(buffer_type, T_ARRAY)) {
size_t total = 0;
for (long i = 0; i < RARRAY_LEN(buffer_type); i++) {
total += io_buffer_buffer_type_size(RB_SYM2ID(RARRAY_AREF(buffer_type, i)));
}
return SIZET2NUM(total);
}
else {
return SIZET2NUM(io_buffer_buffer_type_size(RB_SYM2ID(buffer_type)));
}
}
Returns the size of the given buffer type(s) in bytes.
Example
IO::Buffer.size_of(:u32) # => 4 IO::Buffer.size_of([:u32, :u32]) # => 8