# Ruby apps useing multiple files

**URL:** <https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407>\
**Category:** Ruby\
**Created:** [September 28, 2006, 11:24pm UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407 "2006-09-28T23:24:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nigel\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nigel\_W](https://www.ruby-forum.com/u/Nigel_W)\
**Post date:** [September 28, 2006, 11:24pm UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407/1 "2006-09-28T23:24:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nigel\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nigel\_W](https://www.ruby-forum.com/u/Nigel_W)\
**Post date:** [September 28, 2006, 11:38pm UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407/2 "2006-09-28T23:38:03Z")

</div>

On 9/28/06, Nigel W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![Nigel\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nigel\_W](https://www.ruby-forum.com/u/Nigel_W)\
**Post date:** [September 28, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407/3 "2006-09-28T23:46:03Z")

</div>

Nigel W. wrote:

> 

Use ri to read about “require” and “Kernel#load”.

---

<div class="post-metadata">

**Author:** ![Nigel\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nigel\_W](https://www.ruby-forum.com/u/Nigel_W)\
**Post date:** [September 29, 2006, 12:04am UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407/4 "2006-09-29T00:04:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nigel\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nigel\_W](https://www.ruby-forum.com/u/Nigel_W)\
**Post date:** [September 28, 2006, 11:52pm UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407/5 "2006-09-28T23:52:04Z")

</div>

On Fri, 29 Sep 2006 06:36:44 +0900  
“Jan S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

---

<div class="post-metadata">

**Author:** ![Nigel\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nigel\_W](https://www.ruby-forum.com/u/Nigel_W)\
**Post date:** [September 29, 2006, 11:33am UTC](https://www.ruby-forum.com/t/ruby-apps-useing-multiple-files/70407/6 "2006-09-29T11:33:01Z")

</div>

Nigel W. 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
