Port of https://github.com/tlack/snaphax to Ruby