Appendices: Projects, Interview Questions, Cheat Sheet & Resources
Capstone projects, interview questions, a Ruby cheat sheet, Ruby for Python / JavaScript / Java developers, and resources with a study plan.
Appendix A: Capstone Projects
Beginner: Interactive Quiz Game. Loops, hashes, user input, score tracking, questions loaded from a JSON/YAML file.
Beginner: Personal Expense Tracker CLI. OptionParser, CSV storage, reports by category using group_by/sum, colored output.
Intermediate: Library Management System. Classes, modules (Comparable, Enumerable), custom exceptions, a Data value object, Minitest suite.
Intermediate: Log Analyzer. Regex parsing of large log files with lazy enumerators, statistics with tally, an HTML report using ERB.
Intermediate: REST API with Sinatra or Roda. CRUD endpoints, Sequel + SQLite, JSON, input validation, RSpec + rack-test, Docker.
Advanced: Your Own Gem. Build, test, document (YARD + RBS), and publish a gem (e.g., a slug generator, a retry DSL, or a config loader) with GitHub Actions CI.
Advanced: Testing DSL / Mini-RSpec. describe/it/expect DSL using blocks and instance_eval, with matchers via method_missing.
Advanced: Concurrent Web Crawler. Threads + Queue, or the async gem, rate limiting, robots.txt, Nokogiri parsing, results to SQLite.
Advanced: Task Queue System. Redis-backed job queue (like a mini-Sidekiq): workers in threads/processes, retries with backoff, a web dashboard.
Advanced: Rails Application. A blog/e-commerce app with authentication, Hotwire, Active Storage uploads, background jobs (Solid Queue), system tests, Kamal deployment.
Systems: Native Extension. Implement a hot function as a C or Rust (magnus) extension, benchmark it against pure Ruby, and ship precompiled gems.
Parallelism: Ractor-Based Image Processor. CPU-bound work split across Ractors versus processes, with benchmarks and a report.
Appendix B: Interview Questions
What does "everything is an object" mean in Ruby? Give examples.
What's the difference between puts, print, and p?
Which values are falsy in Ruby?
Symbol vs String: when should you use each?
What's the difference between ==, eql?, equal?, and ===?
Explain nil, &., and ||=.
What's the difference between .. and ...?
What do the ? and ! method suffixes mean?
each vs map vs select vs reduce?
How do hashes with symbol keys differ from string keys?
Methods and Blocks Explain positional, optional, splat, keyword, and double-splat parameters.
What is a block? How do yield and block_given? work?
Proc vs lambda: what are the differences (arity, return)?
What is a closure? Give an example.
What does &:symbol do (Symbol#to_proc)?
What is an Enumerator? What are lazy enumerators for?
How do you make a custom class work with map, select, and sort?
Explain include, extend, and prepend. How does each affect ancestors?
What is the method lookup path?
What is a singleton class (eigenclass)? Where do class methods live?
public, protected, private: how do they differ in Ruby?
Class variables (@@) vs class-level instance variables?
What do super, super(), and super(args) do?
Struct vs Data vs OpenStruct vs a regular class?
How do you implement equality and hashing for objects used as Hash keys?
What is duck typing?
What is metaprogramming? Explain define_method, method_missing, respond_to_missing?, and send vs public_send.
class_eval vs instance_eval vs instance_exec?
What are refinements, and why are they safer than monkey patching?
Explain hook methods (included, inherited, method_added).
How does pattern matching work (case/in, find pattern, pin operator, deconstruct_keys)?
What is the GVL? How do Threads, Fibers, Ractors, and processes differ?
What is the Fiber Scheduler, and what does the async gem do?
How does Ruby's garbage collector work? What are object shapes and compaction?
What are YJIT and ZJIT?
What are RBS and Sorbet? How do they differ?
How does Bundler resolve dependencies? What is Gemfile.lock for?
What is Rack? What does a minimal Rack app look like?
How do you prevent SQL injection, command injection, and unsafe deserialization in Ruby?
How would you profile and speed up a slow Ruby program?
Count word frequencies in a text and print the top 5 (tally, sort_by, first).
Implement a Stack class that includes Enumerable.
Write a method using keyword arguments and a block that retries an operation N times.
Create a Money value object with Data.define, +, and Comparable.
Build a tiny DSL for HTML generation with method_missing.
Flatten a nested hash into dot-notation keys ({a: {b: 1}} → {"a.b" => 1}).
Implement memoized Fibonacci and an infinite lazy prime generator.
Use pattern matching to route parsed JSON events to handlers.
Appendix C: Ruby Cheat Sheet
# ===== Basics =====
name = "Ruby"; age = 30; PI = 3.14; @inst = 1; :symbol
puts "Hello #{name}"; p [1, 2]; gets.chomp
x ||= 5; y = cond ? a : b; user&.email
# ===== Collections =====
arr = [1, 2, 3]; arr << 4; arr.map { it * 2 }; arr.select(&:even?); arr.sum
h = { name: "Ana", age: 30 }; h[:name]; h.fetch(:age); h.each { |k, v| }
(1..5).to_a; %w[a b]; %i[a b]; Set[1, 2]
# ===== Control flow =====
if x > 0 then :pos elsif x < 0 then :neg else :zero end
unless ok then warn "no" end
case v when 1..5 then "low" when String then "str" else "?" end
case data in { name: String => n } then n end
5.times { |i| }; arr.each_with_index { |v, i| }; loop { break }
# ===== Methods =====
def greet(name, greeting = "Hi", *rest, loud: false, **opts, &blk) = "#{greeting}, #{name}"
def square(x) = x * x
sq = ->(x) { x * x }; sq.(3)
def each_item = (return enum_for(:each_item) unless block_given?; @items.each { yield it })
# ===== Classes & modules =====
class Dog < Animal
include Comparable
attr_accessor :name
def initialize(name) = @name = name
def self.create(n) = new(n)
def to_s = "Dog(#{name})"
private def secret = 42
end
module Greet; def hi = "hi #{name}"; end
Point = Data.defin
…ruby app.rb | irb | gem install x | bundle install | bundle exec rspec | rake -T | rubocop -a | rdbg app.rb | ruby --yjit app.rbAppendix D: Ruby for Python / JavaScript / Java Developers
0, "", [], None, False 0, "", null, undefined, NaN, false only nil and false List.of(1, 2) Map.of("a", 1) function f(x) {} int f(int x) {} def f(x)... end lambda x: x * 2 ->(x) { x * 2 } [x*2 for x in xs] xs.map(x => x*2) xs.map { it * 2 } class Dog(Animal): class Dog extends Animal class Dog < Animal self (implicit) interfaces + defaults modules (include) Maven / Gradle Django / Flask Express / Next.js Rails / Sinatra Key gotchas:
Python devs: 0 and "" are truthy, end closes blocks (no significant indentation), methods return the last expression, and blocks replace comprehensions.
JS devs: there's no undefined, integer division truncates (7 / 2 == 3), and strings are mutable unless frozen.
Java devs: there are no type declarations (use RBS/Sorbet optionally), everything is public by default (methods), and open classes allow modifying existing classes.
Appendix E: Resources and Study Plan
ruby-lang.org (downloads, news, documentation), docs.ruby-lang.org (core and stdlib API), rubygems.org, bundler.io, guides.rubyonrails.org
try.ruby-lang.org (browser tutorial), Ruby Koans (rubykoans.com), Exercism Ruby track
*The Well-Grounded Rubyist*: David A. Black & Joseph Leo III *Eloquent Ruby*: Russ Olsen
*Practical Object-Oriented Design (POODR)*: Sandi Metz *Metaprogramming Ruby 2*: Paolo Perrotta
*Programming Ruby 3.3* ("The Pickaxe"): Noel Rappin with Dave Thomas *Effective Ruby*: Peter J. Jones
*Polished Ruby Programming*: Jeremy Evans *Ruby Under a Microscope*: Pat Shaughnessy (internals)
*Agile Web Development with Rails 8*: Sam Ruby et al.
Ruby Weekly newsletter, Ruby Rogues / Remote Ruby / Ruby on Rails podcasts, RubyKaigi and RubyConf talks (YouTube), r/ruby, the Ruby Discord, GoRails, Drifting Ruby, Thoughtbot's blog, Shopify Engineering's Ruby blog 12-Week Study Plan Setup, syntax, variables, numbers
Strings, symbols/nil/truthiness, operators, control flow Arrays, hashes, ranges/sets, methods
Blocks/procs/lambdas, Enumerable/Enumerator Classes, inheritance, modules, object model
Struct/Data, equality/duck typing, exceptions Pattern matching, metaprogramming, DSLs, refinements/hooks, FP
Concurrency, GC/memory, types (RBS/Sorbet) Files, regex, time, data formats, stdlib, HTTP, processes
Bundler, gems, Rake, Minitest, RSpec, debugging/linting, CLIs
Databases, Rack/Sinatra, Rails overview, background jobs 49–54 + Capstone
Performance/YJIT, extensions, security, deployment, internals, idioms
Final tip: Ruby rewards curiosity. Open irb and experiment constantly, read the docs for Enumerable, Array, Hash, and String (they're full of gems of methods), write tests as you go, and read well-written open-source Ruby code (Sinatra, Rack, Rails). Above all, enjoy it: Ruby was made to make programmers happy. 💎