![]() |
Need help getting tutorial started
Hi, I'm in the process of learning Ruby. I've bought a book called Beginning Ruby by Peter Cooper since I am new to programming and wanted to get my feet wet. I've gotten about a sixth of the way through the book and am now attempting to work out some tutorials. The first tutorial involves creating a dummy text file so that I can import it into my IDE (komodo), and then create a text analyzing program for it. So I followed the instructions, created the dummy file, and saved it to where I was instructed to; the same folder where I put this example program (example1.rb). Now the text tells me to put
File.open("text.txt").each { |line| puts line } in a new ruby file(analyzer.rb) I made in my source code editor. The book said that if "text.txt" is in the current directory I should, "see the entire text file flying up the screen". Instead, I got some weird error that goes: C:/Users/will/Desktop/Ruby 1.9.2-p180/ruby_work/analyzer.rb:1:in `initialize': No such file or directory - text.txt (Errno::ENOENT) from C:/Users/will/Desktop/Ruby 1.9.2-p180/ruby_work/analyzer.rb:1:in `open' from C:/Users/will/Desktop/Ruby 1.9.2-p180/ruby_work/analyzer.rb:1:in `<main>' After searching online for a bit I found out that I needed to change my current working directory from "C:/Program Files/ActiveState Komodo Edit 6" to where text.txt is-"C:\Users\will\Desktop\Ruby 1.9.2-p180\ruby_work". When I did this the command output gave me: C:/Users/will/Desktop/Ruby 1.9.2-p180/ruby_work/analyzer.rb:1: syntax error, unexpected $undefined Dir.chdir(C:\Users\will\Desktop\Ruby 1.9.2-p180\ruby_work) All the books and resources that I have available to me give a very cursory introduction to the Dir.chdir feature, but don't show how to use it in much of a practical context. I'm sure I must be doing it wrong. Any suggestions would be greatly appreciated. Thanks |
Get started with Ruby
Try to start here:
One of the best free Ruby books online Programming Ruby Why's Poignant Guide To Ruby is pretty educational. |
All I can see is that the errors suggest you keep flicking between using forward slashes and back slashes in your addresses.
Are you on windows or linux? |
| All times are GMT +1. The time now is 04:44 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.