Appendix A. Ruby Reference
Reference material on Ruby is gathered in this appendix for your convenience. You will
find information about the following: interpreter options, reserved words (keywords),
operators, escape characters, predefined variables, global constants, regular expressions,
String unpack directives, Array pack directives, flags and fields for sprintf, file tests from Kernel#test, time
formatting directives, RDoc options, and Rake options.
Ruby Interpreter
Here is the syntax for the Ruby interpreter:
ruby [switches] [--] [program filename] [arguments]
Switches (or command-line options) include:
−0[octal]Specify record separator (
\0if no argument)-aSet autosplit mode with
-nor-p(splits$_into$F)-cCheck syntax only
-Cdirectorycdto directory before executing your script-dSet debugging flags (set
$DEBUGtotrue)-e 'command'Execute one line of script; several
-e’s allowed; omit[program filename]-Fpatternsplit( )pattern for autosplit (-a)-i[extension]Edit
ARGVfiles in place (make backup if extension is supplied)-IdirectorySpecify
$LOAD_PATHdirectory (may be used more than once)-KkcodeSpecify KANJI (Japanese) code-set
-lEnable line-ending processing
-nAssume
'while gets( ); ... end'loop around your script-pAssume loop similar to
-nbut print line similar tosed-rlibraryRequire the library, before executing your script
-sEnable some switch parsing for switches after script name
-SLook for the script using a PATH environment variable
-T[level]Turn on tainting checks
-vPrint ...
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