From: Avdi Grimm Date: 2008-05-17T01:58:38+09:00 Subject: Re: Pulling a class from a ruby file On Fri, May 16, 2008 at 12:30 PM, Abhishek Ray wrote: > Is there any way in Ruby to load only a single class from another file. No. If you only want the external code the be executed when the file is run as an executable, and not when it is loaded by another file, you can enclose that code in a conditional, thus: if $0 == __FILE__ # ... code to execute when run as an executable ... end I haven't tested the above code. You might need to alter it to make it more robust, along the lines of: if File.expand_path($0) == File.expand_path(__FILE__) # ... end -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com