Running Ruby
Test to see whether Ruby is running on your computer by typing the following at a shell or command prompt:
ruby --version
An affirmative response will look similar to this (this example is for version 1.8.6 running on Mac OS X):
ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.9.0]
You can install Ruby on any of the major platforms. For Ruby file archives and installation instructions, see http://www.ruby-lang.org/en/downloads.
Running the Ruby Interpreter
Usage:
ruby [switches] [--] [program filename] [arguments]
Switches (or command-line options):
-0[octal]Specify a record separator (
\0if no argument).-aAutosplit mode with
-nor-p(splits$_into$F).-cCheck syntax only.
-Cdirectorycdto directory before executing your script or program.-dSet debugging flags (set predefined variable
$DEBUGtotrue).-e 'command'Execute one line of script. Several
-es allowed. Omit [program filename].-Fpatternsplit( )pattern for autosplit (-a).-i[extension]Edit
ARGVfiles in place (make backup if extension supplied).-IdirectorySpecify
$LOAD_PATH(predefined variable) directory; may be used more than once.-KkcodeSpecify the character set. See Table 16.
-lEnable line-ending processing.
-nAssume
'while gets( ); ... end'loop around your script.-pAssume loop like
-nbut print line also likesed.-rlibraryRequire the library before executing your script.
-sEnable some switch parsing for switches after script name.
-SLook for the script using
PATHenvironment variable.-T[level]Turn on tainting checks. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access