I'm afraid this is far from trivial - ruby is script based, and there is no way to stop others from 'tampering' with your code.
There was a discussion about this on https://www.ruby-forum.com/topic/60047, and here is one possible suggestion:
One solution may be to compile a small app that takes an MD5, SHA, or
some other checksum of the ruby code and only executes it if it is in
an internal hash of allowed files. You could have user-based hashes of
allowed files based on who is logged in. Of course you will have to
rebuild this app every time you change the ruby code but that could be
automated. But a user could run the ruby code directly unless you
build in some dependency to the compiled app. If they can see the
source code, they can copy it, tamper with it, and run it.