same ruby file acting standalone resp. as library

T

Thomas Hafner

Hello,

the class definitions of my ruby file shall always be active, whether
the file is run as standalone program or whether the file is used
indirectly by require or load,
*but* when the file is run standalone, a special piece of code within
the file shall be active in addition (a kind of main section).

The idea is that the same ruby code file should be able to act in both
kinds: as a library and as a standalone program which is using that
library functionality.

How can I achieve that easily?

Regards
Thomas Hafner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top