Ruby Cheat Sheet

Complete reference for Ruby language methods, classes, and system variables.

Top Content Ad (Responsive)

Kernel & Core

Pre-defined Variables

Global Variables
  • $! Last Exception Message
  • $@ Backtrace of last exception
  • $_ Last input line (gets)
  • $. Current line number
  • $0 Script name
  • $* Command line arguments (ARGV)
  • $$ Process ID (PID)
  • $? Status of last child process
  • $: Load path
  • $stdin Standard Input
  • $stdout Standard Output
  • $stderr Standard Error
  • ENV Environment Variables (Hash)
  • ARGV Command line args array
  • RUBY_VERSION Ruby Version String
  • RUBY_PLATFORM OS Platform
Regex Variables
  • $& Last match string
  • $` String left of match
  • $' String right of match
  • $1, $2.. Capture groups
  • $~ Last match info object
  • $+ Last bracket matched

Strings & Arrays

Numbers & Math

File, IO & System

Time & Misc

Bottom Content Ad (Responsive)