Getting Started

1. Interactive Ruby—is the tool of choice for executing Ruby interactively. irb is a Ruby shell, complete with command-line history, line-editing capabilities, and job control. Exit an irb session by typing exit or by using the end-of-file character on your operating system (normally Ctrl+D or Ctrl+Z).


2.  On Unix systems, you can use the “shebang” notation as the first line of the program file: #!/usr/bin/ruby


3.  A shebang (also called a hashbang) is the character sequence consisting of the characters number sign and exclamation point (#!), when it occurs as the first two characters on the first line of a text file. In this case, the program loader in Unix-like operating systems parses the rest of the first line as an interpreter directive and invokes the program specified after the character sequence with any command line options specified as parameters. The name of the file being executed is passed as the final argument.


4.  If a source file is documented using RDoc, its documentation can be extracted and converted into HTML and ri formats.


5.  To find the documentation for a class, type ri ClassName . To get a list of classes with ri documentation, type ri with no arguments.


6. Once you find a set of options you like, you can set them into the RI environment variable. Using our shell, this would be done using the following:

$ export RI="--format ansi --width 70"

你可能感兴趣的:(Ruby)