From: Stefano Crocco Date: 2009-05-11T18:10:40+09:00 Subject: Re: Including Module On Monday 11 May 2009, Thangappan Mohana sundaram wrote: > |I am new to Ruby. > |Is there any way to include the module in normal ruby file? > | > |For an example, > | > |Test.rb > | > |Class Test.rb > | ........ > |end > | > |testing.rb > | > |object = Test.new # It tells error. Add: require 'Test' to testing.rb before calling Test.new (assuming that Test.rb and testing.rb are in the same directory and that you run ruby from that directory). Also, notice that: 1) you should write class Test, not class Test.rb (note the downcase c in class and the absence of the .rb from Test). Class names have nothing in common with file names 2) file names are (I think) case senstive in ruby, so if you call your file Test.rb you'll need to require 'Test'; if you call it test.rb you'll need to require 'test'. If you're on windows, which is not a case sensitive OS, you may be used to a different behaviour (actually, I'm not completely sure of how this behaves on windows, as I've never used ruby on it) 3) modules in ruby are something entirely different (see the documentation for the Module class either at http://www.ruby-doc.org/core/ or using ri: ri Module. For more information you can look at the documentation for the require method of module Kernel, either at http://www.ruby-doc.org/core/ or using ri: ri Kernel#require. You may also find useful reading the free online version of the Pickaxe book (http://www.ruby-doc.org/docs/ProgrammingRuby/) it's a bit outdated, but it should be useful all the same. I hope this helps Stefano