Wednesday, 8 January 2014

Ruby - Download and Install Ruby






If you want to try out Ruby programming language, then run your Ruby scripts and programs, you’re going to need to install Ruby on your system first. That may seem obvious to some, but unlike say HTML, JavaScript and VBScript that can run with what’s on the system, Ruby isn’t sat there out of the box.

Download and Install
To download, you can go to a couple of locations, either https://www.ruby-lang.org/en/downloads/ or as shown in the YouTube Video, hit http://rubyinstaller.org/ for Windows. Hit the big [Download] button and select the latest version.









Once installed, hit the Windows [Start] menu, type CMD and open a command window.  Then type ruby -v to check the installation had worked as expected.






Ruby comes with IRB or “Interactive RuBy”, which allows you to try out some basic commands. Personally, I wouldn’t bother with it as it’s trivial to start making scripts you can save and edit with ease. To have a look, just type irb in the command window and IRB will start. If you see a warning message, don’t worry. Check out the video at 2m 30s (http://youtu.be/bO_SqGs2vRk?t=2m30s) for instructions about how to get rid of it by commenting out the warning line.









To store the scripts we’ll start making, add a folder on the C:\ drive. Add a ‘Ruby’ folder or something that you’ll remember is for your projects. To run Ruby, we’ll need to call the scripts using the command window we just played with. I suggest you tweak it slightly by changing the background colour, size, etc. to make it a bit more comfortable to work with. To do this, click on the title bar at the top, then select ‘Properties’. Adjust to your hearts content, the main things are to make the window bigger and perhaps get rid of the retina searing white background.

First Script
Back in your Ruby folder that you just created, add a new .txt file but change the extension to .rb to make this associated with Ruby. Call it test.rb perhaps. If you double-click it, nothing will happen. Well, you may see what looks like a command window flash open and closed, but nothing really exciting. Let’s add exciting…

Open the file in whatever editing software you have, I use SciTe but even Notepad will work. In the file type the classic first line:  puts “Hello World!” then hit save. To run this, you need to go to the command window, navigate to the folder where the file is and type: test.rb to invoke your file. If all has gone well, you’ll see Hello World! On your screen.











That’s it, Ruby installed and working! Onwards and upwards,  go take over the world… or have a look at the video and read the other Ruby blog posts here!


1 comments: