Learn Ruby

Quizzes

Beginner

Beginner Ruby Quiz #1
Variables, strings, and numbers
Beginner Ruby Quiz #2
Ruby practice questions on arrays, conditionals, and while loops
Quiz #3
Variable scope and methods
Quiz #4
Symbols, array methods, and hashes
Quiz #5
Intro object oriented programming
Quiz #6
Iteration and nested data structures
Quiz #7
Modules, classes, and inheritance

Intermediate

Ruby Array Quiz
Closer look at Ruby's Array class
Hash quiz
Grokking the Hash class
Object Oriented Programming
Instance variables, constants, self, and message sending
More OOP
Monkey patching, attr_*, modules, and singleton methods
Inheritance
Inheritance path, overwriting methods, and super
Object Oriented Design
Creating flexible and maintainable software
Code Blocks
Methods that use code blocks

Advanced

Singleton Class
Singleton methods, inheritance, and method lookup
Scopes
Scope gates, bypassing scopes, and top level context
Closures and Bindings
First class procs and binding objects
Object model and privacy
Private / protected methods and instance variables
Modules
Including and extending
Method Missing
Metaprogramming Ruby

Ruby TDD

Quiz #1
String and Integer code for RSpec tests
Quiz #2
RSpec Array quiz

Books

The Well-Grounded Rubyist

  • Difficulty: Intermediate
  • Rating: 10/10

The Well Grounded Rubyist is the best book to learn about objects and message sending. Messages are more important that objects and David Black gives messages the attention they deserve.

David doesn't even introduce the if keyword until page 150! This is not your typical programming book.

The Well Grounded Rubyist is the best way to level up from a beginner to an intermediate Ruby programmer.

Make sure to read The Well Grounded Rubyist before Practical Object Oriented Design in Ruby and Metaprogramming Ruby.

Practical Object-Oriented Design: An Agile Primer Using Ruby (2nd Edition)

  • Difficulty: Advanced
  • Rating: 10/10

Practical Object Oriented Design in Ruby (POODR) is a masterfully written book on object oriented design.

Programmers cannot predict the future, but we can design code so it can easily be adapted to incorporate future feature requests. POODR explains how to write well designed code that is easy to change.

POODR talks about message sending a lot so make sure to read The Well Grounded Rubyist first.

Metaprogramming Ruby 2: Program Like the Ruby Pros (Facets of Ruby)

  • Difficulty: Advanced
  • Rating: 10/10

Metaprogramming Ruby continues where The Well Grounded Rubyist leaves off.

Metaprogramming is code that writes code. It's awesome and fun!

The book covers a lot of core Ruby concepts that are critical to understand metaprogramming: Ruby's object model, method lookup, and module.

Once the foundation is laid, basic metaprogramming concepts like define_method and method_missing are covered.

Before you know it, you will be writing a domain specific language with Ruby!

You will be a Ruby expert after reading this book.

Beginning Ruby: From Novice to Professional

Beginning Ruby was written in 2011 by Peter Cooper, an influental member of the Ruby community.

Beginning Ruby is a bit scattered and jumps into technical concepts very quickly, so it's not suitable for beginners.

An experienced programmer would learn a lot from Beginning Ruby, but there are other books that are much easier to follow.

Online Learning Resources

Try Ruby

Try Ruby is a 15 minute tutorial on the very basics of Ruby. All code is run in the browser.

Unlike the other tutorials, Try Ruby isn't scary! They ease you into the material.

In level 5 the tutorial covers the Dir module, which is confusing because the code is running the browser and the file system isn't visible.

Learn Ruby the Hard Way

Learn Ruby the Hard Way is written by the controversial author Zed Shaw. He wrote Rails is a Ghetto in 2007 and people didn't really like it. Nonetheless, people seem to love his books.

Zed is right that learning to program requires a lot of practice and persistence. Repetition is how you learn.

The first 39 lessons are approachable and the course gets much harder when modules, classes, and objects are introduced in lesson 40. If example 40 scares you, just stop reading and move on to the next learning resource.

Zed wraps up the book with some bizzare Advice from an Old Programmer. I love working as a full-time programmer and absolutely do not agree with "Programming as a profession is only moderately interesting". I think programmers at technology companies are respected and do not agree that "People who can code in the world of technology companies are a dime a dozen and get no respect".

Use Zed's learning resources and ignore his angry rants.

Codecademy

Codecademy gives little descriptions of key programming concepts and provides a Ruby shell to evaluate your knowledge during each step. The lessons are build towards people that are not familiar with Ruby and have never programmed before.

The course is for beginners, but the code gets scary and complex quickly.

Scary Ruby code

The first line in the method (puts "That's not an integer." unless n.is_a? Integer) uses a lot syntactic sugar and would even be difficult for experienced programmers that are not familiar with Ruby to read.

Codecademy is demonstrating how this code can be broken up with methods, but this is still very scary for newbies.

Codecademy also jumps into procs and lambdas quickly. New Ruby programmers don't need to know how to yield with parameters.

Yielding with parameters

Parts of Codecademy are great and other parts are terrifying and should be skipped. You might not know what parts should be skipped so the course might make you feel bad.

Ruby Lang Quickstart

The Ruby Lang quickstart tutorial starts off as a promising interactive Ruby console (irb) based introduction to the language and quickly becomes too complicated.

The tutorial quickly asks you to write an 11 line class in your irb console:

irb(main):024:0> class Greeter
irb(main):025:1>   def initialize(name = "World")
irb(main):026:2>     @name = name
irb(main):027:2>   end
irb(main):028:1>   def say_hi
irb(main):029:2>     puts "Hi #{@name}!"
irb(main):030:2>   end
irb(main):031:1>   def say_bye
irb(main):032:2>     puts "Bye #{@name}, come back soon."
irb(main):033:2>   end
irb(main):034:1> end

This code is certain to baffle a newbie programmer. An experienced programmer would prefer to write all this code in a text editor.

This tutorial can be used by an inexperienced programmer, but newbies should stay away.

RubyMonk

RubyMonk jumps right into objects in the first lesson. This course is suitable for experienced programmers and beginners should stay away.

Introduction to Objects

Once you are comfortable with the fundamentals of Ruby, this is a great course to level up.