On Tue, 12 Jul 2005, mathew wrote:

> Joel VanderWerf wrote:
>> Why not just begin your main .rb file with
>> 
>> $LOAD_PATH.unshift Dir.pwd
>> 
>> and then you can let users put the dir wherever they want?
>
> Because that way you need to change to the directory where the files are, 
> before running the program.
>
> What would be really useful would be a way to find the path to the currently 
> executing Ruby file. Then you could stick that on the LOAD_PATH to let the 
> program find all the other files.
>
> (I had a look, but couldn't find such a thing.)

dirname, basename = File::split(File::expand_path(__FILE__))
$:.unshift dirname

or maybe better

$:.unshift(File::join(dirname, "share"))

hth.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple.  My religion is kindness.
| --Tenzin Gyatso
===============================================================================