Interactive roadmap
Ruby roadmap
Designed for beginners who want to build clean applications. You will learn to write readable code and understand object-oriented programming.
- 1
Ruby Basics
0 of 4 done
Get started with basic syntax and data types.
Take your time playing with small code snippets in the console to build your confidence early on. - 2
Working with Collections
0 of 3 done
Organise multiple items using arrays and hashes.
Think of collections as organised filing cabinets that keep your data tidy and easy to find. - 3
Blocks and Iterators
0 of 3 done
Pass chunks of code around using blocks.
Blocks might feel tricky at first, but practice will show you how much cleaner they make your code. - 4
Objects and Classes
0 of 3 done
Build object-oriented programs with classes.
Object-oriented programming helps you model real-world things cleanly in your code. - 5
Modules and Gems
0 of 3 done
Share code and use external packages.
Explore the wider Ruby community to find wonderful tools built by other developers.
Learn it all, with a tutor that never sleeps
Every topic links to LevelUp lessons, practice exercises and the 24/7 AI Tutor. Your progress updates as you master lessons.
Every topic explained
Step 1: Ruby Basics
- Store data like numbers and text using variables. This lets your code remember information as it runs.Ruby Documentation
Read more
Variables are simply labelled boxes that store information inside your computer memory. When writing Ruby, you create a variable by giving it a name and assigning it a value using the equals sign. For example, writing username equals alice sets aside a space in memory containing that text.
This matters because programs need to remember data as they run. Without variables, your code could not track user scores, shopping basket items, or settings. They form the foundation of every application you will ever build.
- Variables store data values in memory
- Use the equals sign for assignment
- Ruby handles types behind the scenes
- Names should describe the data inside
- Group reusable chunks of code into methods. This keeps your programs organised and avoids repeating yourself.
Read more
Methods are named chunks of code that perform a specific task when called. Instead of writing the same instructions repeatedly, you wrap them in a method and run it whenever needed. For instance, a calculate_total method can take item prices and return the final sum.
This keeps your programs organised and much easier to maintain. If business rules change, you only update the code in one place rather than hunting through hundreds of lines. It is a vital step toward writing clean, professional Ruby code.
- Methods group reusable logic together
- Defined using the def keyword
- Can accept inputs called arguments
- Always return the last evaluated expression
- Make decisions in your code using if and unless statements. This allows your program to react differently to various inputs.
Read more
Control flow allows your program to make decisions based on changing conditions. Using statements like if and unless, you tell Ruby to run specific blocks of code only when certain criteria are met. Imagine an online shop checking if a user is logged in before showing their basket.
This capability turns static scripts into dynamic applications that react intelligently to user input. It matters because real-world software must handle different scenarios, errors, and user choices gracefully every single second.
- Directs which code runs next
- Uses if, else, and elsif statements
- Evaluates conditions to true or false
- Keeps applications responsive to user actions
- (optional)
- Experiment with code quickly using the interactive Ruby console. It is a handy tool for testing small snippets.
Read more
IRb stands for Interactive Ruby, a built-in tool that lets you run Ruby code line by line in your terminal. You type an expression, press enter, and immediately see the result. It acts as a safe scratchpad to test ideas without creating full files.
This tool is brilliant for beginners because it provides instant feedback when learning syntax or testing built-in methods. You will use it constantly throughout your coding journey to experiment quickly before writing larger programs.
- Provides instant feedback on code
- Runs directly inside your terminal
- Great for testing small snippets
- Helps debug unfamiliar syntax quickly
Step 2: Working with Collections
- Store ordered lists of items in arrays. You can add, remove, and find items easily by their position.
Read more
An array is an ordered list that holds multiple items inside a single variable. You can store numbers, strings, or even other arrays inside it, and each item sits at a numbered position starting from zero. Think of a shopping list where item zero is milk and item one is bread.
Arrays matter because applications frequently deal with groups of similar items, such as a list of registered users or search results. Knowing how to add, remove, and sort array items is an essential everyday coding skill.
- Stores ordered lists of items
- Positions start counting at zero
- Can hold mixed data types
- Easy to add or remove elements
- Store information using key-value pairs in hashes. This is useful for looking up data by a specific name.
Read more
A hash is a collection that stores data using key-value pairs rather than numerical positions. Instead of remembering that an item is at index two, you look it up by a descriptive label called a key. Think of it like a real contact book where you look up a phone number using a person's name.
Hashes are crucial for representing structured information, such as user profiles with names, emails, and ages. They make your code readable because the labels clearly explain what each piece of data represents.
- Uses key-value pairs for storage
- Keys act as descriptive labels
- Fast lookups by specific names
- Replaces numbered indexes with meaning
- Go through every item in a collection using each loops. This lets you perform actions on multiple pieces of data.
Read more
Iteration is the process of going through every item in a collection one by one to perform an action. Using an each loop, you can tell Ruby to process every element without writing repetitive code. For example, you can send an email notification to every user in a mailing list array.
This technique is fundamental for handling bulk data efficiently. As your applications grow, you will constantly process lists of records, making iteration one of your most frequently used tools.
- Visits every item in a collection
- Uses the each method in modern Ruby
- Avoids repetitive manual code writing
- Processes bulk data safely and cleanly
Step 3: Blocks and Iterators
- Pass anonymous chunks of code to methods using blocks. They help you write concise and flexible code.
Read more
A block is an anonymous chunk of code enclosed in curly braces or do and end keywords that you pass to a method. It lets you inject custom behavior into standard methods without writing a brand new loop from scratch. Think of it as handing a specific instruction manual to a helper tool.
Blocks are a hallmark of idiomatic Ruby, making code concise and expressive. They allow methods to handle heavy lifting while letting you decide the exact detail of what happens to each item.
- Anonymous chunks of executable code
- Written with curly braces or do end
- Passed directly into methods
- Keeps code DRY and flexible
- Execute custom blocks inside your own methods using the yield keyword. This lets callers customise method behaviour.
Read more
The yield keyword is a special command inside a Ruby method that pauses execution and runs any block passed by the person calling that method. It acts as a handover point where custom logic can be plugged in dynamically. For instance, a logger method could yield to custom code before recording timestamps.
This matters because it lets you build flexible methods whose exact behavior can be decided later by whoever calls them, forming the bedrock of advanced Ruby programming patterns.
- Triggers the block passed to a method
- Allows callers to customise behavior
- Can pass data back into the block
- Empowers reusable method design
- (optional)
- Search and filter collections effortlessly using built-in helper methods. They save you from writing manual loops.
Read more
Enumerable methods are a powerful set of built-in tools included with Ruby collections that handle searching, sorting, and filtering. Instead of writing manual loops with if statements to find matching items, you use methods like select or find. Think of it as a smart sieve that filters out exactly what you need.
These methods save you massive amounts of time and make your intentions crystal clear to other programmers reading your code. Mastering them is a major milestone in your Ruby education.
- Built-in tools for searching and filtering
- Includes methods like select and find
- Replaces messy manual loops
- Makes data manipulation readable and concise
Step 4: Objects and Classes
- Define blueprints for objects using classes. Every object you create can have its own data and behaviours.
Read more
A class acts as a blueprint or template for creating objects in Ruby. While a string or array is an object built by Ruby, classes let you define your own custom data types with specific behaviors. For example, a User class can define how every user in your app behaves.
Classes matter because they organise large programs into manageable, logical pieces. By grouping related data and actions together, your code becomes much easier to understand, test, and expand over time.
- Blueprints for creating custom objects
- Bundles data and behavior together
- Defined using the class keyword
- Organises large programs logically
- Give objects their own state using instance variables and reader methods. This lets individual objects remember details.
Read more
Instance variables give individual objects their own unique state and memory. While methods define what an object can do, instance variables define what it knows, such as a dog's name or a bank account balance. Reader and writer helpers let you safely access and update this private data.
This is essential because real-world objects have unique properties that change over time. Instance variables ensure that each object maintains its own identity independently of other objects.
- Store unique data inside individual objects
- Names always begin with an @ symbol
- Accessor helpers make reading data easy
- Gives each object its own state
- Share code between related classes using inheritance. This stops you from duplicating code across similar blueprints.
Read more
Inheritance allows a new class to adopt behaviors and attributes from an existing parent class. Instead of duplicating common code across similar blueprints, you create a general parent class and let specific child classes inherit from it. For example, an AdminUser and GuestUser can both inherit from a base User class.
This mechanism stops you from repeating yourself and keeps your codebase DRY. If a shared feature needs updating, you fix it once in the parent class and every child benefits instantly.
- Shares code between related classes
- Child classes inherit parent features
- Uses the less-than symbol for setup
- Eliminates code duplication effectively
Step 5: Modules and Gems
- Group related methods together or mix behaviours into classes using modules. This keeps your code modular and tidy.
Read more
A module is a container that groups related methods and constants together under one name. Unlike classes, you cannot create direct instances of a module. Instead, you use them as toolboxes or mix them into classes to share behavior across unrelated blueprints.
Modules keep your codebase modular, tidy, and free of naming conflicts. They are the primary way Ruby solves the challenge of sharing code when strict inheritance does not quite fit your design.
- Containers for methods and constants
- Cannot be instantiated directly
- Mixed into classes using include
- Prevents naming conflicts across projects
- Install and manage external libraries using Rubygems and Bundler. This gives you access to thousands of community-built tools.
Read more
Rubygems is the official package manager for Ruby, and Bundler helps manage them in your projects. Gems are pre-written libraries created by the community that handle complex tasks like parsing data, connecting to databases, or building websites.
Instead of writing everything from scratch, you can install trusted gems with a simple command. This gives you instant access to thousands of powerful tools, allowing you to focus on building your unique application features.
- Packages of community-built code
- Managed using Bundler and Rubygems
- Saves time on complex features
- Easily added to project dependency files
- (optional)
- Check that your code works correctly by writing automated tests. This gives you confidence when making changes.
Read more
Writing tests involves creating automated code that checks whether your main program behaves exactly as expected. Using testing frameworks like Minitest, you write assertions that verify your methods return correct outputs under various conditions.
This gives you immense confidence when refactoring or adding new features because your automated suite catches bugs instantly before they reach real users. It is an industry-standard practice for writing reliable software.
- Automates checks on your code
- Catches bugs before reaching production
- Builds confidence when refactoring
- Uses frameworks like Minitest