Ruby — Command Reference
Ruby's most used commands and methods — simple, readable, and enjoyable. Each with an explanation and a working example.
8 categories · 32 commands
🖥️
Output & Input
Printing to the screen and embedding values into text.
puts / print / pString interpolation ( #{} )gets📦
Variables
Variables and constants.
variableConstant (UPPERCASE)🔢
Numbers & Math
Arithmetic and mathematical methods.
Arithmetic ( + - * / % ** )round / floor / ceil / absMath.sqrt / rand✍️
String
String methods: length, transformation, replacement, splitting.
.lengthupcase / downcase / capitalizestrip / chompgsub / sub+2📋
Array
Ordered data and powerful array methods.
arr [ ]push / << / popinclude? / indexmap+3🗂️
Hash (Dictionary)
Key-value mappings.
hash { }fetch / keys / valueseach (hash)🔁
Condition & Loop
Decision making and repetition.
if / elsif / elseTernary operator / unlesscase / whentimes / upto / each+1🧩
Method & Class
Defining methods (functions) and classes.
defDefault parameterclass / initialize