Ruby itself is designed to load and run files, but doesn't have an interface for interactive use. For interactive use, use 'irb'. You can start up interactive Ruby, and type expressions to be evaluated. Use the load function to load in a program file. Type control-d to exit.
The Lab has version 1.9.3 installed, which is the latest stable release. (There seem to be minor differences regarding the patch version on Windows vs. linux - that shouldn't matter for 341.)
Open a command shell, either by running cmd (a Windows shell) or a cygwin bash shell. Use the cd command to switch to the directory where your Ruby file is (using the Windows shell you separate directories with backward slashes (\) and with cygwin you use forward slashes (/)). After you are in the right directory, type irb to start the Ruby REPL. If you are running a batch program (for example running unit tests), use
ruby mytests.rb
Interactive Ruby also lives under All Programs > DEV TOOLS & LANGUAGES > Ruby 1.9.3-p194 > Interactive Ruby. “Documentation” provides online documentation. However, to load files it will be more convenient to start irb from a command shell, so that you can be in the correct directory before starting Ruby.
Type irb at the prompt to get Interactive Ruby. If the long prompt is getting annoying you can start it with
irb --prompt simpleinstead.
To run Ruby on a program file type
ruby yourfilename.rb
The unit test framework doesn't work out of the box with the linux version of Ruby 1.9.3. To make it work, type this at the command prompt:
gem install minitestYou only need to do this once.
You may already have Ruby on your machine -- for example, version 1.8.7 comes bundled with Lion on the Macintosh. This is an older version but should be OK. (We will keep an eye out for any incompatibilities.) However, the TAs will be testing your programs using 1.9.3, so if you're using an older version, please test test your program on 1.9.3 (for example on attu) before turning it in.
You can download Ruby for various platforms from the Ruby home page. It's free.