Skip to content

Ruby Tutorials

In this tutorial, you'll learn about Ruby Tutorials. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Ruby is a dynamic, object-oriented scripting language known for its elegant syntax and developer happiness. It powers Ruby on Rails, one of the most popular web frameworks, and tools like Jekyll, Sidekiq, and Chef.

1. What is Ruby?
History, philosophy, Matz, Ruby vs Python
2. Installation & Setup
rbenv, RVM, irb, gem, first program
3. Variables & Types
Dynamic typing, symbols, strings, integers
4. Control Flow
if/unless, case/when, ternary, truthiness
5. Loops & Iteration
each, while, until, times, upto, loop
6. Arrays
Array methods, map, select, reduce, sort
7. Hashes
Hash syntax, symbol keys, fetch, merge
8. Methods
def, return, implicit return, splat, keyword args
9. Classes & Objects
class, initialize, attr_accessor, self
10. Modules
module, include, extend, prepend, namespace
11. Inheritance
< operator, super, ancestors chain
12. Blocks & Procs
blocks, yield, Proc.new, &, call
13. Lambdas
->, lambda, arity, closure
14. Mixins
Comparable, Enumerable, custom mixins
15. Duck Typing
respond_to?, method_missing, dynamic dispatch
16. Open Classes
Monkey patching, refinements, Module#prepend
17. Strings
Interpolation, gsub, split, freeze, encodings
18. Regular Expressions
=~, match, scan, named captures
19. File I/O
File, IO, Dir, CSV, JSON parse
20. Exception Handling
begin/rescue, ensure, raise, custom exceptions

Intermediate & Advanced

21. Enumerable
each, map, select, reduce, group_by, chunk
22. Date & Time
Time, Date, DateTime, strftime
23. Serialization
Marshal, YAML, JSON dump/load
24. Logging
Logger, log levels, formatted output
25. Rails Setup
rails new, MVC, directory structure
26. Active Record
Models, migrations, validations, associations
27. Action Pack
Controllers, routes, params, sessions
28. Action View
ERB, partials, helpers, layouts
29. Migrations
Migration types, rollbacks, indexes
30. Associations
belongs_to, has_many, through, polymorphic
31. Validations & Callbacks
validates, before_save, after_create
32. Testing Rails
RSpec, FactoryBot, Capybara, system tests
33. Method Missing
method_missing, respond_to_missing?
34. Define Method
define_method, class_eval, instance_eval
35. send & respond_to
send, public_send, respond_to?
36. Const Missing
const_missing, autoloading
37. Hooks
included, extended, inherited, method_added
38. DSL Building
Block-based DSL, instance_exec
39. Concurrency
Thread, Mutex, Queue, Ractor
40. Fibers
Fiber, scheduler, non-blocking I/O
41. Gems & Bundler
Gemfile, gemspec, Bundler, publishing
42. Performance
Profiling, Benchmark, memory, JRuby
43. Ruby 3 Features
Ractors, Fiber scheduler, pattern matching
44. Type Checking
Sorbet, RBS, steep, type signatures
45. Project: CLI App
Build a CLI todo app
46. Project: REST API
Build a REST API with Sinatra
47. Project: Web App
Build a blog with Rails
48. Project: Data Pipeline
Build an ETL pipeline
49. Gem Development
Create and publish your own gem
50. Ruby Ecosystem
Sinatra, Hanami, Jekyll, Sidekiq, Devise

Published Topics

What is Ruby? History, Philosophy and Key Features Explained

Ruby is a dynamic, object-oriented scripting language created by Yukihiro Matsumoto, designed for developer happiness and elegant, readable code.

✓ Live

Ruby Installation Guide — Set Up Ruby on Linux, macOS and Windows

Learn how to install Ruby using rbenv, RVM, or package managers on any operating system with interactive console and gem package manager setup.

✓ Live

Ruby Variables and Data Types Explained — Dynamic Typing and Symbols

Ruby variables use dynamic typing where any variable can hold any type. Learn symbols, strings, integers, floats, booleans, and nil with examples.

✓ Live

Ruby Control Flow Explained — if unless case when Ternary and Truthiness

Ruby control flow includes if/unless, case/when, and ternary operators with unique truthiness rules where only nil and false are falsy values.

✓ Live

Ruby Loops and Iteration — each while until times and Enumerable Explained

Ruby loops include each for collections, while/until with conditions, times/upto for counting, and loop for infinite iteration with break control.

✓ Live

Ruby Arrays — Complete Guide with Methods map select reduce and sort

Ruby arrays are ordered, integer-indexed collections with powerful methods like map, select, reduce, sort, and each that make data transformation expressive.

✓ Live

Ruby Hashes Complete Guide — Symbol Keys fetch merge and Hash Syntax

Ruby hashes are key-value dictionaries that support symbol keys, string keys, default values, fetch with fallback, merge, transform, and selective iteration.

✓ Live

Ruby Methods Explained — def return Implicit Return Splat and Keyword Arguments

Ruby methods defined with def support implicit returns, splat arguments for variable parameters, keyword arguments with defaults, and method visibility control.

✓ Live

Ruby Classes and Objects — class initialize attr_accessor and self Explained

Ruby classes define objects with state and behavior using initialize constructors, attr_accessor for attribute management, and self for method context.

✓ Live

Ruby Modules — include extend prepend and Namespace Organization Explained

Ruby modules organize reusable code with include for mixins, extend for class methods, prepend for method override priority, and namespaces for avoiding collisions.

✓ Live

Ruby Inheritance — Superclass < Operator super Keyword and Ancestors Chain

Ruby inheritance uses the < operator for class hierarchies, super to invoke parent methods, and the ancestors chain showing the complete method lookup path.

✓ Live

Ruby Blocks and Procs — yield Proc.new Call and Block Passing Explained

Ruby blocks are anonymous code blocks passed to methods, Proc objects encapsulate blocks for reuse, and the & operator converts between blocks and procs.

✓ Live

Ruby Lambdas — Arrow Syntax Lambda Arity and Closure Behavior Explained

Ruby lambdas created with -> or lambda keyword are stricter closures that check argument arity and return from the lambda itself rather than the enclosing method.

✓ Live

Ruby Mixins — Comparable Enumerable and Custom Mixin Patterns Explained

Ruby mixins use modules to share behavior across classes, with Comparable and Enumerable being the most powerful built-in mixins for comparison and iteration.

✓ Live

Ruby Duck Typing — respond_to? method_missing and Type Flexibility Explained

Ruby duck typing focuses on what an object can do (its methods) rather than what it is (its class), enabling flexible polymorphic code through respond_to? and method_missing.

✓ Live

Ruby Open Classes — Monkey Patching Refinements and Safe Modification Explained

Ruby open classes allow modifying existing classes at runtime including core classes like String and Array, with refinements providing scoped modification for safer code.

✓ Live

Ruby Strings — Interpolation gsub split freeze and Encoding Explained

Ruby strings support interpolation with #{} for embedding expressions, gsub for pattern substitution, split for tokenization, freeze for immutability, and encoding.

✓ Live

Ruby Regular Expressions — =~ match scan and Named Captures Explained

Ruby regular expressions use =~ for matching, match for MatchData objects, scan for all matches, and named captures for extracting specific groups by name.

✓ Live

Ruby File I/O — File IO Dir CSV and JSON Parsing Explained

Ruby file I/O covers File class operations, IO streams, Dir directory traversal, CSV parsing, and JSON serialization for structured data processing.

✓ Live

Ruby Exception Handling — begin rescue ensure raise and Custom Exceptions

Ruby exception handling uses begin/rescue blocks to catch errors, ensure for cleanup, raise to trigger errors, and custom exception classes for domain-specific errors.

✓ Live

Ruby Enumerable — each map select reduce group_by and chunk Explained

Ruby Enumerable provides 50+ collection methods through each including map, select, reduce, group_by, chunk, and partition for powerful collection operations.

✓ Live

Ruby Date and Time — Time DateTime Date Parsing and Formatting Explained

Ruby Date and Time classes provide comprehensive temporal data handling with Time for timestamps, Date for calendar dates, and DateTime for combined date-time operations.

✓ Live

Ruby Marshal Serialization — dump load and Object Persistence Explained

Ruby Marshal provides serialization for saving and restoring Ruby objects with dump for writing and load for reading, supporting most built-in types and custom objects.

✓ Live

Ruby Logging — Logger, Log Levels, Formatting and Best Practices Explained

Ruby Logging uses the built-in Logger class for application logging with configurable log levels, output destinations, format customization, and rotation strategies.

✓ Live

Ruby on Rails Setup — rails new MVC Architecture and Directory Structure Explained

Ruby on Rails setup uses rails new to generate a full MVC application with models, views, controllers, helpers, and a structured directory following convention over configuration.

✓ Live

Ruby Active Record — ORM Queries Migrations and Relationships Explained

Ruby Active Record is Rails' ORM layer that maps database tables to Ruby classes, providing CRUD operations, query interfaces, relationships, and lifecycle callbacks.

✓ Live

Ruby Action Pack — Controllers Routing Filters and HTTP Handling Explained

Ruby Action Pack is Rails' controller and routing layer that handles HTTP requests, processes parameters, manages sessions, and renders responses through controllers and middleware.

✓ Live

Ruby Action View — ERB Templates Partials Helpers and Layouts Explained

Ruby Action View is Rails' view layer that renders HTML templates using ERB, with partials for reusable components, helpers for view logic, and layouts for consistent page structure.

✓ Live

Ruby on Rails Migrations — Schema Changes Data Types and Rollbacks Explained

Ruby on Rails Migrations manage database schema changes over time using Ruby DSL for creating tables, adding columns, changing data types, and safely rolling back changes.

✓ Live

Ruby on Rails Associations — belongs_to has_many has_one and has_many_through Explained

Ruby on Rails Associations define relationships between models including belongs_to, has_many, has_one, and has_many :through for efficient data access and query optimization.

✓ Live

Ruby on Rails Validations — Presence Uniqueness Custom and Callbacks Explained

Ruby on Rails Validations ensure data integrity with built-in helpers for presence, uniqueness, length, format, and custom validation methods triggered before database save.

✓ Live

Ruby Testing with RSpec — Factories Mocks System Tests and TDD Explained

Ruby Testing with RSpec provides behavior-driven testing for Rails applications with factory_bot for fixtures, mocks for isolation, system tests for browser testing, and TDD workflow.

✓ Live

Ruby Metaprogramming — define_method send and Dynamic Code Generation Explained

Ruby Metaprogramming enables writing code that writes code using define_method for dynamic method creation, send for dynamic dispatch, and eval for runtime code execution.

✓ Live

Ruby Domain-Specific Languages — Building Fluent Interfaces and Internal DSLs Explained

Ruby Domain-Specific Languages (DSLs) create fluent, readable APIs using blocks, method_missing, instance_eval, and chaining for natural-language-like code interfaces.

✓ Live

Ruby send and define_method — Dynamic Dispatch and Method Creation Explained

Ruby send and define_method provide dynamic dispatch and runtime method creation, enabling flexible metaprogramming patterns, dynamic accessors, and method delegation.

✓ Live

Ruby method_missing — Ghost Methods Dynamic Proxies and Delegation Explained

Ruby method_missing intercepts calls to undefined methods enabling ghost methods, dynamic proxies, delegation patterns, and automatic method generation at runtime.

✓ Live

Ruby const_missing — Dynamic Constant Resolution and Autoloading Patterns Explained

Ruby const_missing intercepts references to undefined constants, enabling autoloading patterns, dynamic constant generation, and Rails-style automatic file loading.

✓ Live

Ruby eval and Binding — Runtime Code Evaluation and Context Execution Explained

Ruby eval executes arbitrary strings as code at runtime, with binding capturing execution context for deferred evaluation, enabling DSLs, REPLs, and dynamic code generation.

✓ Live

Ruby Performance Optimization — Profiling Caching YJIT and Memory Management Explained

Ruby Performance Optimization covers profiling with benchmark and stackprof, caching strategies, YJIT JIT compilation, memory management, and reducing object allocations.

✓ Live

Ruby Threads — Concurrent Programming with Thread Class, Mutex and Queue

Ruby threads enable concurrent execution using Thread class with mutex for synchronization, Queue for safe data sharing, and ThreadGroup for lifecycle management.

✓ Live

Ruby Fibers — Lightweight Concurrency with Fiber Class and Transfers

Ruby Fibers provide cooperative concurrency with explicit control flow using Fiber class, resume and yield methods, and transfers between fibers.

✓ Live

Ruby Ractors — Parallel Execution Without the GIL with Ractor Class

Ruby Ractors provide true parallel execution without the GIL using isolated actors communicating through message passing with Ractor class, select, and receive.

✓ Live

Ruby Gems — Creating, Publishing and Managing Gems with Gem Tools

Ruby Gems are self-contained packages of Ruby code shared via RubyGems with tools for creation, building, versioning, and publishing to rubygems.org.

✓ Live

Ruby Bundler — Dependency Management with Gemfile and Bundler Commands

Bundler manages Ruby gem dependencies through Gemfile specification with install, exec, and update commands for reproducible application environments.

✓ Live

Ruby Mini Projects — Build Real Applications Using Ruby Concepts

Ruby mini projects applying classes, metaprogramming, threads, and gems to build a CLI task manager, web scraper, file watcher, and API client.

✓ Live

Ruby Ecosystem — Community, Frameworks, Tools, and Best Practices Guide

Ruby ecosystem includes Rails for web development, Sinatra for microservices, RSpec for testing, and community tools like RuboCop, Bundler, and Rake.

✓ Live

Ruby Advanced Testing — RSpec Mocks, Stubs, Factories, and Integration Testing

Ruby advanced testing covers RSpec mocks and stubs for isolation, FactoryBot for test data, Capybara for integration testing, and VCR for external API calls.

✓ Live

Ruby Deployment — Deploying Ruby Applications with Docker, Capistrano, and Cloud Platforms

Ruby deployment strategies include Docker containers for consistency, Capistrano for server automation, and cloud platforms like Render, Heroku, and Fly.io.

✓ Live

Ruby Web APIs — Building RESTful APIs with Sinatra, Rails API, and Grape

Ruby web APIs are built with Sinatra for lightweight services, Rails API mode for full-featured APIs, and Grape for DSL-based RESTful endpoints.

✓ Live

Ruby Advanced Topics — DSLs, Macros, and Internals for Expert-Level Ruby

Ruby advanced topics cover DSL creation with class-level macros, Ruby internals including AST and bytecode, C extensions, and JRuby/TruffleRuby differences.

✓ Live

All 50 topics in Ruby Tutorials are published.