Joel VanderWerf
5/17/2008 8:49:00 PM
Avdi Grimm wrote:
> On Fri, May 16, 2008 at 12:30 PM, Abhishek Ray <hey_a_ray@hotmail.com> 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
or put the external code inside of some specialized construct:
def external
yield unless $testing
end
external do
class C
end
def foo
end
end
C
foo
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407