From: Michael Guterl Date: 2006-09-05T09:28:52+09:00 Subject: Re: How do I create an instance of a class in another rb file ------=_Part_36231_13180559.1157416128647 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/4/06, brian.kejser@protexis.com wrote: > > Hi > > Thanks. > > I thought 'require' only imported files in the Ruby lib folder. powerbook:~ michaelguterl$ ri require --------------------------------------------------------- Kernel#require require(string) => true or false ------------------------------------------------------------------------ Ruby tries to load the library named _string_, returning +true+ if successful. If the filename does not resolve to an absolute path, it will be searched for in the directories listed in +$:+. If the file has the extension ``.rb'', it is loaded as a source file; if the extension is ``.so'', ``.o'', or ``.dll'', or whatever the default shared library extension is on the current platform, Ruby loads the shared library as a Ruby extension. Otherwise, Ruby tries adding ``.rb'', ``.so'', and so on to the name. The name of the loaded feature is added to the array in +$"+. A feature will not be loaded if it's name already appears in +$"+. However, the file name is not converted to an absolute path, so that ``+require 'a';require './a'+'' will load +a.rb+ twice. require "my-library.rb" require "db-driver" -----Original Message----- > From: "Logan Capaldo" > Sent: Mon, September 4, 2006 16:33 > To: "ruby-talk ML" > Subject: Re: How do I create an instance of a class in another rb file > > > On Sep 4, 2006, at 7:21 PM, brian.kejser@protexis.com wrote: > > > Hi > > > > I have two rb files in the same folder. > > > > The first file is one.rb and defines an instanciable class named > > 'One'. > > The second file is two.rb and needs to create an instance of class > > 'One' > > as defined in one.rb. > > > > How do I import the class 'One' into two.rb? > > > > require 'one' > one = One.new > > > > Thanks > > > > > > > > > > > > > > ------=_Part_36231_13180559.1157416128647--