From: "Brian Schröder" Date: 2005-07-22T20:30:59+09:00 Subject: Re: Are there packages? On 22/07/05, EdUarDo wrote: > Hi, I'm new to Ruby. I'm going to start a new project and I'd like > to know how could organize the classes. > I want to make a directory structure that allows me to have the classes > ordered and organized, like I'd do with C or Java. > > How must I reference a class X from class Y if class X is in different directory? > Is there a variable like CLASSPATH or anything else? > How have I to specify where are my classes? > > Thanks. > > You need not put each class in a file. Normally you put each chunk of logically connected code into on file, that may well be more than one class, or in special cases also only half a class. Then you require the files into the main file and start using the classes. E.g. main.rb: --- require 'ui_1.rb' require 'ui_2.rb' class Datastructure ... end class Program def initialize @ui1 = UI1.new(42) @ui2 = UI2.new("Hello world") end ... end Program.new --- ui_1.rb: --- class UI1 .... end --- ui_2.rb: --- class UI2 .... end --- etc. regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/