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

    Unhappy Beginner Ruby: How to actually start

    Ok so I went on codecademy.com/org whatever it is, and I learned how to code somewhat in ruby, BUT, i have no idea where to put any code I make. If i put it into a text document, how do i let the computer recognize that it has to use ruby? I generally use ubuntu linux but am currently on redhat linux (in case it differs) Could you please help? Thank you !

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Command line execute
    You can use a shebang as well, and execute the ruby script. Assuming /usr/bin/env contains the ruby:
    PHP Code:
    #!/usr/bin/env ruby

    def PrintMaName(name)
        
    puts "Ruby sez: hello #{name}"
    end

    PrintMaName
    ("Fou-Lu"
    And run it up. You can use gets as well to actually prompt. If you want it to execute with the shebang, make sure you add the +x for the execution as well. Don't forget as well you can use the locate or which command to tell you where an executable is. Use that for your shebang path

    I'll be starting to use ruby more often as well; just gotta get beyond the re-learn curve.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    quibble42 (07-25-2013)

  • #3
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Not sure about how to do what you're saying.
    You might have to walk me through the steps... is the usr/bin etc. in the text doc. or is it the directory for terminal?

  • #4
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can start on http://tryruby.org/levels/1/challenges/0
    or you could read this free book online http://ruby.learncodethehardway.org/book/
    or maybe this guide (which is pretty fun to read) http://mislav.uniqpath.com/poignant-...chapter-1.html
    Last edited by VIPStephan; 09-02-2013 at 05:20 PM. Reason: Removed fake signature


  •  

    Tags for this Thread

    Posting Permissions

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