Loading .rb files in IRb

G

Gudni Hilmarsson

Hi..

I am trying to get IRb to load a file. I am running a fresh install of
Mac OS X Leopard and I have updated my gems and RubyGems. Below is the
Class file ( From the Pickaxe and saved under /Users/gudni/Song.rb ) and
the results from my previous attempts.

Attempt 1:
--> LoadError: no such file to load -- /Users/gudni/Song.rb
from (irb):3:in `load'
from (irb):3

Attempt 2:
-->LoadError: no such file to load -- /Users/gudni/Song.rb
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
from (irb):5

I can't get it to work. According to the pickaxe it should be enough to
give the full path to the file, but it doesn't seem to work for me. Any
help would be much appreciated :D

P.S. Happy holidays :D

class Song
def initialize(name, artist, duration)
@name = name
@artist = artist
@duration = duration
end

def to_s
"Song: #@name--#@artist (#@duration)"
end
end


Content of my $:
/Library/Ruby/Gems/1.8/gems/wirble-0.1.2/bin
/Library/Ruby/Gems/1.8/gems/wirble-0.1.2/.
/Library/Ruby/Site/1.8
/Library/Ruby/Site/1.8/powerpc-darwin9.0
/Library/Ruby/Site/1.8/universal-darwin9.0
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc-darwin9.0
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0
 
F

F. Senault

Le 24 décembre à 13:14, Gudni Hilmarsson a écrit :
Attempt 1:

--> LoadError: no such file to load -- /Users/gudni/Song.rb
from (irb):3:in `load'
from (irb):3

It really should work. Note that path and file names are probably
case-sensitive, though. You can try to use Dir.glob to list the
contents of the directory :
=> ["/home/fred/toto.rb", "/home/fred/main.rb"]

Fred
 
G

Gudni Hilmarsson

Thanks for the Reply Fred...

I figured out that TextMate added a whitespace after .rb !

Dir.glob('/Users/gudni/*')
=> ["/Users/gudni/Desktop", "/Users/gudni/Documents",
"/Users/gudni/Downloads", "/Users/gudni/KaraokeSong.rb ",
"/Users/gudni/Library", "/Users/gudni/Movies", "/Users/gudni/Music",
"/Users/gudni/Pictures", "/Users/gudni/Public", "/Users/gudni/Sites",
"/Users/gudni/Song.rb ", "/Users/gudni/test.rb "]

That is whack :D

Anyway thanks for pointing me in the right direction :D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top