Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Thanked 0 Times in 0 Posts

    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 06:22 AM. Reason: updating question

  2. #2
    New Coder
    Join Date
    Aug 2011
    Thanked 2 Times in 2 Posts

    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.

  3. #3
    New Coder
    Join Date
    Jan 2011
    Thanked 0 Times in 0 Posts
    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?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts