On Monday, February 10, 2003, 5:47:46 AM, Jason wrote:

> Daniel Carrera wrote:
>> Say I have "mod.rb" installed, and in "file.rb" I call it with:
>> require "mod"
>> 
>> I need "mod.rb" to know in which directory *it* is installed.  
>> Unfortunatelly, it interprets the current directory to be the current 
>> directory of "file.rb", as opposed to its own.
>> 
>> How can "mod.rb" find its own current directory?

> f = __FILE__
> len =  -f.length

> my_dir = File::expand_path(f)[0...len]

Better:

  my_dir = File.dirname(__FILE__)

Gavin