How to compile a portable version of Ruby - eviltoast

I love using Ruby, but one problem I have always had is distributing my programs made with it.

I would love to be able to distribute a version of Ruby in an AppImage; I want to make programs for the Steam Deck, and for most users this requires programs to be locally installed only. AppImages are perfect for this.

I managed to make an AppImage running an ancient version of Ruby from the PortableRuby project, but I would like to be able to use modern Ruby. Are there any tips/tricks I should know to compile a portable version?