Ruby apps useing multiple files

Hi folks

I'm writing an app in ruby and want to split it into more than one file
to make it more manageable. How do I get the main file to include the
others. Do I use some sort of include, require or load command or is
there some sort of library command like TCL has.

Cheers
Nigel

require 'filename' is the proper one. you can use load 'filename' if
you want to reload the file each time load is called (require loads
the file only once)

$: is load path, where require/load look for files (NB: it's an Array)

J.

···

On 9/28/06, Nigel Wilkinson <nigel@waspz.co.uk> wrote:

Hi folks

I'm writing an app in ruby and want to split it into more than one file
to make it more manageable. How do I get the main file to include the
others. Do I use some sort of include, require or load command or is
there some sort of library command like TCL has.

Cheers
Nigel

Nigel Wilkinson wrote:

Hi folks

I'm writing an app in ruby and want to split it into more than one file
to make it more manageable. How do I get the main file to include the
others. Do I use some sort of include, require or load command or is
there some sort of library command like TCL has.

Cheers
Nigel

Use ri to read about "require" and "Kernel#load".

Thanks for that, however the "is load path" reference confuses me, I
can't find a reference to it in "Ruby in a nutshell". Can you point me
to a reference please or give an example of its use.

Cheers
Nigel

···

On Fri, 29 Sep 2006 06:36:44 +0900 "Jan Svitok" <jan.svitok@gmail.com> wrote:

On 9/28/06, Nigel Wilkinson <nigel@waspz.co.uk> wrote:
> Hi folks
>
> I'm writing an app in ruby and want to split it into more than one
> file to make it more manageable. How do I get the main file to
> include the others. Do I use some sort of include, require or load
> command or is there some sort of library command like TCL has.
>
> Cheers
> Nigel

require 'filename' is the proper one. you can use load 'filename' if
you want to reload the file each time load is called (require loads
the file only once)

$: is load path, where require/load look for files (NB: it's an Array)

J.

the global variable $:
is a synonym for $LOAD_PATH
which is an array of paths to search for required/loaded files

···

On Sep 28, 2006, at 5:51 PM, Nigel Wilkinson wrote:

On Fri, 29 Sep 2006 06:36:44 +0900 > "Jan Svitok" <jan.svitok@gmail.com> wrote:

On 9/28/06, Nigel Wilkinson <nigel@waspz.co.uk> wrote:

Hi folks

I'm writing an app in ruby and want to split it into more than one
file to make it more manageable. How do I get the main file to
include the others. Do I use some sort of include, require or load
command or is there some sort of library command like TCL has.

Cheers
Nigel

require 'filename' is the proper one. you can use load 'filename' if
you want to reload the file each time load is called (require loads
the file only once)

$: is load path, where require/load look for files (NB: it's an Array)

J.

Thanks for that, however the "is load path" reference confuses me, I
can't find a reference to it in "Ruby in a nutshell". Can you point me
to a reference please or give an example of its use.

Cheers
Nigel

Nigel Wilkinson wrote:

$: is load path, where require/load look for files (NB: it's an Array)

J.

Thanks for that, however the "is load path" reference confuses me, I
can't find a reference to it in "Ruby in a nutshell". Can you point me
to a reference please or give an example of its use.

Ruby in a Nutshell: Section 3.1 Predefined Variables

···

--
Posted via http://www.ruby-forum.com/\.