Gavin Kistner
10/17/2006 3:45:00 AM
Scott D_o wrote:
> Gavin Kistner wrote:
> > a) What is the name of the file that you put your class in?
> > b) Where is the file, relative to the file that has the "require" line
> > in it?
>
> Ok so here is some code that is having the problem with the require. I
> tested out some programs from rubyforge, and it gave me the same error.
> -----------------------------------------------------------------
> TestClass two seperate files
> -----------------------------------------------------------------
> class TestClass
> def testMethod()
> return "Hello I am in TestClass"
> end
> end
>
> -----------------------------------------------------------------
> ClassTester
> -----------------------------------------------------------------
> require 'TestClass'
>
> ob = TestClass.new()
> puts("Testing: #{ob.testMethod()}")
You didn't answer either of my questions.
What is the name of the FILE that you have your TestClass defined in?
It should be something like "testclass.rb". That's what you should put
in your require statement, e.g.
require 'testclass.rb'
Also, unless you're installing it somewhere in your require path, you
should have that file in the same directory as your 'class tester' file.