Harry Ohlsen <harryo / zip.com.au> wrote in message news:<2J097.72441$Xr6.328607 / news-server.bigpond.net.au>... > James Arendt wrote: .... > > In Java, one can use Class.forName or a classloader directly such as > > the RMIClassLoader. So, to load class myPackage.Simple it would be: > > > > Class.forName("myPackage.Simple"); > > > > Where is an equivalent feature in Ruby to be found? > > Since Ruby execution is totally dynamic, the equivalent, I guess, would be > simply using "require" as necessary. > > For example, if you had code like ... > > if x < 10 > require 'simple' > ... > end > > then the classes defined in simple.rb (which could be anywhere in your ruby > library path) would be loaded if x is less than 10, but not if it wasn't. > > You can also (and I only found this out from the mailing list the other > day) use "load 'simple.rb'" if you want to always re-load the code in > simple.rb, as opposed to using "require", which will only load it the first > time the given file is "require"ed. That may be closer to what you were > looking for, I guess. Both of those makes sense and would mostly achieve what I need. The area where I also would like to be able to load classes is over the network. I'm assuming that require and load are the two main ways, right? If that's the case, I see two chief ways for me to achieve network-based class loading.... * Download the file(s) from a server and save to the disk. Once saved locally, load them as one would with any other file. * Better way probably would be to perhaps override the original load or require to accept URL based paths instead of using only file system paths. Has anyone done something similar to this? Or, as a newbie, will I be embarking on a journey into uncharted territories with Ruby in hand? :) James