I’m having trouble following along with some of the examples in this
"Beginning Ruby(2nd Edition). I’m at the section where you learn about
I/O handling and tried to do one of the examples and got an error. Not
sure what I did wrong:
irb(main):001:0> File.open(“olivertext.txt”) do |f|
irb(main):002:1* puts f.gets
irb(main):003:1> end
Errno::ENOENT: No such file or directory - olivertext.txt
from (irb):1:in initialize' from (irb):1:inopen’
from (irb):1
from C:/Ruby193/bin/irb:12:in `’
I tried to use the whole directory to find the file, and got this:
<“C:\Users\Al Baker\Documents\Programming\RuBy olivertext.txt”) do |f|
irb(main):005:1* puts f.gets
irb(main):006:1> end
Errno::ENOENT: No such file or directory -
C:UsersAlBakerDocumentsProgrammingRuBy olivertext.txt
from (irb):4:in initialize' from (irb):4:inopen’
from (irb):4
from C:/Ruby193/bin/irb:12:in `’
help!
Thanks. I wish they could’ve included that in the book.
I also had problems using the ‘Profile’ in irb. I used the code in the
book:
require ‘profile’
class Calculator
def self.count_to_large_number
x = 0
100000.times {x += 1 }
end
def self.count_to_small_number
x = 0
1000.times {x += 1 }
end
end
but only got ‘100000’ and ‘1000’ when I called the methods o for Small
and large number. smh!
Errno::EACCES: Permission denied - C:/Users/Al
Baker/Documents/Programming/RuBy/
NewDir
from (irb):62:in delete' from (irb):62 from C:/Ruby193/bin/irb:12:in’
i alreeady did the gem install and copied the “libmysql.dll” over to bin
but still got this:
irb(main):005:0> require ‘mysql’
LoadError: cannot load such file – mysql/mysql_api
from
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n require' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i nrequire’
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.0-x86-mingw32/lib/mys
ql.rb:6:in rescue in <top (required)>' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.0-x86-mingw32/lib/mys ql.rb:2:in<top (required)>’
from
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n require' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i nrequire’
from (irb):5
from C:/Ruby193/bin/irb:12:in `’