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:
load '/Users/gudni/Song.rb'
--> LoadError: no such file to load -- /Users/gudni/Song.rb
from (irb):3:in `load'
from (irb):3
Attempt 2:
require '/Users/gudni/Song.rb'
-->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
P.S. Happy holidays
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 $:
puts $:
/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
.
=> nil
and my irbrc
# Some default enhancements/settings for IRB, based on
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
# Require RubyGems by default.
require 'rubygems'
require 'wirble'
# Activate auto-completion.
require 'irb/completion'
# Use the simple prompt if possible.
IRB.conf[:PROMPT_MODE] = :SIMPLE if IRB.conf[:PROMPT_MODE] == :DEFAULT
# Setup permanent history.
HISTFILE = "~/.irb_history"
MAXHISTSIZE = 100
begin
histfile = File::expand_path(HISTFILE)
if File::exists?(histfile)
lines = IO::readlines(histfile).collect { |line| line.chomp }
puts "Read #{lines.nitems} saved history commands from
'#{histfile}'." if $VERBOSE
Readline::HISTORY.push(*lines)
else
puts "History file '#{histfile}' was empty or non-existant." if
$VERBOSE
end
Kernel::at_exit do
lines = Readline::HISTORY.to_a.reverse.uniq.reverse
lines = lines[-MAXHISTSIZE, MAXHISTSIZE] if lines.nitems >
MAXHISTSIZE
puts "Saving #{lines.length} history lines to '#{histfile}'." if
$VERBOSE
File::open(histfile, File::WRONLY|File::CREAT|File::TRUNC) { |io|
io.puts lines.join("\n") }
end
end
···
--
Posted via http://www.ruby-forum.com/\.