Trying to load a .rb file in irb

I am trying to load a ruby program into irb and it will not load.

i have tried typing:

load ’ personal_chef.rb’

load 'personal_chef.rb ’

As well as using the entire path name and I always get the same message:

LoadError: cannot load such file

     from<irb>:1:in 'load'
     from<irb>:1

I have ruby version 2.00 and its on windows 7.

Any ideas? I feel like this is a simple problem like spacing or
something, but I just can’t figure it out…

I also tried require for all of the text listed above and that didnt
work either

Am 13.06.2013 22:35, schrieb Eric D.:

I am trying to load a ruby program into irb and it will not load.

i have tried typing:

load ’ personal_chef.rb’

load 'personal_chef.rb ’

why do you put whitespace in the path?

try

load ‘personal_chef.rb’

Tried it exactly as you wrote it and the same error message arose.

I put the white space in because one of the other forums said that some
of the text editors(sublime, textmate etc. add white spaces)

Try Dir.pwd to see where irb is looking for the file. You might need the
full path.

I did that it says C:/Users/Eric.

Is there anyway I can change the directory to some other location?

Am 13.06.2013 22:35, schrieb Eric D.:

I am trying to load a ruby program into irb and it will not load.

Make sure you start irb from the directory where the file is located.
You can list the files in that directory with

Dir[’*’]

If you see your file on this list, load ‘file.rb’ should work.

Otherwise you need to specify the full path.

Dir.chdir should change the path to whatever you specify. If you want to
change the starting path you’ll need to launch irb with the command
prompt when you’re in your chosen folder, or add a command to your
.irbrc file.

The directory change worked! Thank you both for your help. One question
though, when I try to load a text file from a program in ruby it says

undefined method `each’ for “text.txt”:String (NoMethodError).

My code looks like this:

File.open (“text.txt”).each {|line| puts line}

Both the text.txt and the program loading it are in the same directory.

Any suggestions?

Am 18.06.2013 23:27, schrieb Eric D.:

though, when I try to load a text file from a program in ruby it says

undefined method `each’ for “text.txt”:String (NoMethodError).

My code looks like this:

File.open (“text.txt”).each {|line| puts line}

File.open(“text.txt”).each {|line| puts line }

Never put a space between method name and ‘(’.

BTW. When you figure it out by yourself, you should also include
the solution in your “Never mind” post. In case other people
have a similar problem.

Never mind i figured it out. Thank you guys! Great forum!

Apologies. On the loading issue that I eluded to early it was the
spacing mentioned in unknown (Guest)'s post.

I’d use
File.foreach( ‘text.txt’ ) {|line| puts line }