francisrammeloo / hotmail.com wrote:
> Hi all,
> 
> Suppose I have following code:
> 
> require "./Classes/Printer" # My personal printer class
> 
> 
> Now if I want to run my program Ruby needs to find the Printer.rb file
> in the Classes directory. But if the script was run like this:
> 
> 
>>cd ~
>>ruby ~/rubydev/projects/texteditor/main.rb
> 
> 
> 
> Then the current path will be ~ and Ruby won't find
> ../Classes/Printer.rb
> How do I solve this problem?

require File.join(File.dirname(__FILE__), 'Classes', 'Printer')

Jim
-- 
Jim Menard, jimm / io.com, http://www.io.com/~jimm
"I am sure that like Java, [C#] will be a 'no pointer' language, where the
most common runtime error will be a 'NULL pointer exception'."
    -- Jerry Kott, in comp.lang.smalltalk