Irb newbie question

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

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

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

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.

This should have worked. Can we see your code?

···

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

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

Hi Eero,

The load File.expand_path('~/classes.rb) that you mentioned did the trick.

Thanks again for your help!

--Nick

···

On Aug 20, 2006, at 10:21 AM, Eero Saynatkari wrote:

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

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