# Irb newbie question

**URL:** <https://www.ruby-forum.com/t/irb-newbie-question/65686>\
**Category:** Ruby\
**Created:** [August 20, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/irb-newbie-question/65686 "2006-08-20T16:14:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Parsons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/41988e/32.png) [@Nicholas\_Parsons](https://www.ruby-forum.com/u/Nicholas_Parsons)\
**Post date:** [August 20, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/irb-newbie-question/65686/1 "2006-08-20T16:14:48Z")

</div>

Hello All!

I’m new to Ruby and this group. I was hoping that someone could lend  
a helping hand involving the irb interpreter packaged with ruby  
version 1.8 on Mac OSX. I would like to import or load some classes  
that are defined in a separate .rb file on my hard disk into an  
interactive session of irb. I tried invoking the load() function  
with ‘~/classes.rb’ as a parameter. The interpreter gave me a ‘true’  
value in response. But when I tried to create an instance of one of  
the classes defined in the file I got a undefined class error from  
irb. I also tried using the require keyword with the same path in  
quotes to load that class file and it produced the same results.

So, can anyone tell me how to import those class definition ruby  
files into the irb interpreter or at least point me in the right  
direction on where to find documentation online for the irb  
interpreter itself?

I appreciate everyone’s help in advance.

Thanks & Regards,  
–Nick

“Our characters are the result of our conduct.” – Aristotle

---

<div class="post-metadata">

**Author:** ![Nicholas\_Parsons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/41988e/32.png) [@Nicholas\_Parsons](https://www.ruby-forum.com/u/Nicholas_Parsons)\
**Post date:** [August 20, 2006, 4:21pm UTC](https://www.ruby-forum.com/t/irb-newbie-question/65686/2 "2006-08-20T16:21:06Z")

</div>

Nicholas Parsons wrote:

> Hello All!
> 
> I’m new to Ruby and this group. I was hoping that someone could lend  
> a helping hand involving the irb interpreter packaged with ruby  
> version 1.8 on Mac OSX. I would like to import or load some classes  
> that are defined in a separate .rb file on my hard disk into an  
> interactive session of irb. I tried invoking the load() function  
> with ‘~/classes.rb’ as a parameter. The interpreter gave me a ‘true’  
> value in response. But when I tried to create an instance of one of  
> the classes defined in the file I got a undefined class error from  
> irb. I also tried using the require keyword with the same path in  
> quotes to load that class file and it produced the same results.
> 
> So, can anyone tell me how to import those class definition ruby  
> files into the irb interpreter or at least point me in the right  
> direction on where to find documentation online for the irb  
> interpreter itself?
> 
> I appreciate everyone’s help in advance.

One thing to try is load ‘/home/myname/classes.rb’ or,  
alternatively, load File.expand\_path(’~/classes.rb’).  
Wildcards generally cause problems with filename  
strings unless expanded.

Not sure why you are getting ‘true’ unless it is actually  
finding the file–it could of course be that the file itself  
is missing something or you are not accessing the namespace  
or something.

> Thanks & Regards,  
> –Nick

---

<div class="post-metadata">

**Author:** ![Nicholas\_Parsons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/41988e/32.png) [@Nicholas\_Parsons](https://www.ruby-forum.com/u/Nicholas_Parsons)\
**Post date:** [August 20, 2006, 4:22pm UTC](https://www.ruby-forum.com/t/irb-newbie-question/65686/3 "2006-08-20T16:22:48Z")

</div>

On Aug 20, 2006, at 10:14 AM, Nicholas Parsons wrote:

> undefined class error from irb. I also tried using the require  
> keyword with the same path in quotes to load that class file and it  
> produced the same results.

This should have worked. Can we see your code?

---

<div class="post-metadata">

**Author:** ![Nicholas\_Parsons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/41988e/32.png) [@Nicholas\_Parsons](https://www.ruby-forum.com/u/Nicholas_Parsons)\
**Post date:** [August 20, 2006, 4:30pm UTC](https://www.ruby-forum.com/t/irb-newbie-question/65686/4 "2006-08-20T16:30:49Z")

</div>

Hi Eero,

The load File.expand\_path(’~/classes.rb) that you mentioned did the  
trick.

Thanks again for your help!

–Nick
