in reply to conditional self-execution
- A common Ruby idiom involves creating all the classes and methods necessary for a given program and for other programs that might want to use them as in a library call, then in its own little section write the code that makes use of those classes and methods, creating something that works equally well as either a library or a stand-alone script.
OK -- after reading and re-reading the first sentence of your post, I think I understand the concept.
So what's the point? It just strikes me as a clever piece of code, a solution looking for a problem. It makes more sense to me to just write a module, which is really just a library of related subroutines and variables, and call it from a script, which is just the main-line.
And I'm asking this in the nicest possible way -- I'm not trashing Ruby, just I'm really puzzled as to why one would write something like this.
In Section
Seekers of Perl Wisdom