From: Eko Budi Setiyo Date: 2005-01-11T13:10:39+09:00 Subject: Re: file location Thanks you very much Joel VanderWerf wrote: > Eko Budi Setiyo wrote: > >> Hi everybody >> >> >> #file1.rb >> #Location: /home/eko >> puts Dir.pwd require 'directory1/file2.rb >> >> >> #file2.rb >> #Location: /home/eko/directory1 >> puts Dir.pwd >> >> >> >> if I run "ruby file1.rb >> will produce: >> "/home/eko" >> "/home/eko" >> >> What comand that I should you in file2.rb that will "automatically" >> produce result >> "/home/eko" >> "/home/eko/directory1/file2.rb" > > > #file1.rb > puts Dir.pwd # /tmp > require 'directory1/file2.rb' > > > #file2.rb > puts Dir.pwd # /tmp > > Dir.chdir(File.dirname(__FILE__)) do > puts Dir.pwd # /tmp/directory1 > end > > puts Dir.pwd # /tmp > > (But note that Dir.chdir with a block is not threadsafe.) > > >