I’ve been a bit slow in my learning of Ruby. This time around I’ve re-written Ozan Yigit’s ndbm clone: sdbm.
I’ve cheated a bit. My general plan has been to pick things up through re-writing bits of existing code in Ruby: but to do them from memory (swotting up if necessary) rather than translate them directly. In this particular case it was convenient (for testing) to ensure that my implementation produced files that were bit-for-bit identical to those produced by the original (as incorporated into Perl). So, to avoid incompatibilities, I wrote down the string hash algorithm and the block sizes used for reading and writing the files. It was only a tiny cheat.