You probably learned on your first day of programming Ruby that you can invoke Ruby from the command line by passing it the filename of a script to run:
$ ruby foo.rb
This will execute the code found in foo.rb, but otherwise it won’t do anything too special. If you’ve ever written Ruby on the command line, you’ll definitely have started Ruby in this way.
What you might not know is that by passing options to the ruby command, you can alter the behavior of the interpreter. There are three key options that will make life much easier when writing one-liners in the shell. The first is essential, freeing you from having to store code in files; the second and third allow you to skip a lot of boilerplate code ...