End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
DBM#to_hash
dbm.to_hash → hash
ext/dbm/dbm.c
View on GitHub ↗
static VALUE
fdbm_to_hash(VALUE obj)
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
VALUE hash;
GetDBM2(obj, dbmp, dbm);
hash = rb_hash_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
rb_hash_aset(hash, rb_str_new(key.dptr, key.dsize),
rb_str_new(val.dptr, val.dsize));
}
return hash;
}
Converts the contents of the database to an in-memory Hash object, and returns it.