Possibly a better approach which might simplify things - being able to deal with existing backups which might be *.gz or *.zst - is to use tar’s automatic detection:
tar --auto-compress -c -f ../file.tar.gz .
tar --auto-compress -c -f ../file.tar.zst .
More important for the unpacking, of course, where we might not know what we’re going to see.
Presently the ruby code seems to do lots of things which tar itself can do. Hopefully this can be simplified, rather than becoming more complex.