ruby
TLDR
Start an interactive Ruby session (IRB)
SYNOPSIS
ruby [options] [-e command] [programfile] [arguments]
DESCRIPTION
ruby is the interpreter for the Ruby programming language. It executes Ruby scripts or runs interactive sessions, providing a dynamic, object-oriented environment for general-purpose programming.
Ruby emphasizes programmer happiness and productivity with elegant syntax. Everything is an object, and the language supports multiple programming paradigms: object-oriented, functional, and imperative.
The -e option allows quick one-liners without creating a file. Combined with -n or -p, Ruby becomes a powerful text processing tool similar to awk or perl.
For interactive exploration, use irb (Interactive Ruby) or pry for enhanced REPL features.
PARAMETERS
-e command
Execute command as one line of script-c
Check syntax only, don't execute-w
Enable warnings-W level
Set warning level (0=silent, 1=medium, 2=verbose)-d, --debug
Enable debug mode-v, --verbose
Print version and enable verbose mode--version
Print version and exit-n
Wrap script in while gets() ... end loop-p
Like -n but print $_ after each iteration-a
Auto-split mode (with -n or -p), sets $F-i [ext]
In-place edit mode (backup with extension if given)-I dir
Add directory to load path-r library
Require library before executing-S
Search for script in PATH-x [dir]
Extract script from message and change to dir
CAVEATS
Ruby versions can differ significantly. Use version managers like rbenv or rvm to manage multiple Ruby installations.
Gem dependencies should be managed with Bundler. Run scripts with bundle exec to ensure correct gem versions.
Ruby's global interpreter lock (GIL/GVL) limits true parallelism in threads. Use processes or specialized libraries for CPU-bound parallelism.
HISTORY
Ruby was created by Yukihiro "Matz" Matsumoto in Japan, with the first public release in 1995. Matz designed Ruby to be more powerful than Perl and more object-oriented than Python. Ruby gained worldwide popularity with the Ruby on Rails web framework released in 2004.


