Go Back   CodingForums.com > :: Server side development > Ruby & Ruby On Rails

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-23-2011, 06:29 AM   PM User | #1
gwp5008
New to the CF scene

 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
gwp5008 is an unknown quantity at this point
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

Last edited by gwp5008; 07-25-2011 at 05:22 AM.. Reason: updating question
gwp5008 is offline   Reply With Quote
Old 08-18-2011, 08:01 PM   PM User | #2
dotnetmind
New Coder

 
Join Date: Aug 2011
Posts: 50
Thanks: 0
Thanked 2 Times in 2 Posts
dotnetmind is an unknown quantity at this point
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.
dotnetmind is offline   Reply With Quote
Old 11-03-2011, 12:04 PM   PM User | #3
CrazyCrisUk
New Coder

 
Join Date: Jan 2011
Posts: 42
Thanks: 5
Thanked 0 Times in 0 Posts
CrazyCrisUk is an unknown quantity at this point
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?
CrazyCrisUk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:59 AM.


Advertisement
Log in to turn off these ads.