Along the lines of ghostdog74's answer, I would first ask what your objective is. You don't necessarily need to close source a program to make money off of it, or even to make money off of licensing it. A lot of companies have dual licensing models for their open source products, which means the source code is all out there (or at least 98% of it is), but they're still charging licensing fees for certain use cases (e.g. commercial uses, or commercial use in organizations with more than X number of users).
Also, most scripting-language-based products are web/intranet applications. And with a lot of web apps there just isn't any point in trying to hide the code, even if it is closed source. In most cases there's really nothing novel about the implementation of a particular product, and what you're selling to customers is just:
- a pre-packaged solution that works and saves the customer the time/money it costs to develop their own in-house application
- commercial support and quality guarantees
- a feature set that sets this product apart from others on the market.
None of these selling points receive any sort of benefit or protection from concealing the source code. Number 2 is the same regardless of whether the source is open or closed. Selling points 1 and 3 can both be undermined by IP infringement, but source code availability is irrelevant in both cases. Someone can pirate your software just as easily if the source code were hidden or obfuscated, and your competitors don't need your source code to copy your feature set.
There are cases where one may want to protect a proprietary algorithm or formula (e.g. if you've not secured a patent on it yet or are seeking to achieve security through obscurity), but I'd wager to say that for most projects, obfuscating your source code is a moot point.
We have legislation in place to protect intellectual property. So, unless you're selling a product on the black market, concealment of source code would only serve to protect the parts of your source code that cannot be considered your intellectual property.
Edit:
Obviously a lot of people don't feel this actually answers the question, and I can understand that sentiment. I do generally try to give direct answers to questions, except when there might be a better/simpler way to achieve the poster's goals than the approach taken by the question.
So, yes, you could conceal your code by compiling it into an intermediate language or using a code obfuscator, but there isn't any point IMO. If someone wants to see your original source code, they can just decompile it, and even commercial code obfuscators like RubyEncoder have proven easy to defeat.
I don't know enough about metaprogramming in Ruby to say with any confidence whether it will work for this application or not, but my gut tells me that the concept is likely as fundamentally flawed as DRM.