Course

Ruby Foundations

Learn the fundamentals to become a Ruby and Rails developer. You'll learn things like what Ruby is, how to write object oriented Ruby, classes and modules, programming structures and types, and more. There are no requirements for this course other than a web browser and willingness to learn.

Now that you have Ruby installed and have written your first program, try writing another program that prints your name three times. This will involve the use of iteration! Check out the documentation for the "times" method for help.

Input and Printing

Write a small Ruby program that asks you what your name is. Have the program print out the number of characters in your name. Also have the program print out a message if your name is longer than 25 characters.

The Ruby Numbers badge will get you comfortable working with numbers in Ruby. This badge teaches you about integers, floating point numbers, math, and more. You'll learn how to create and work with numbers, compare numbers, and work with currency.

Try writing a Ruby program that asks a user to input numbers and then multiplies them together. Have the program print out the result to two decimal places regardless of whether or not the user entered an integer or floating point number.

Symbols as Hash Keys

A method is a set of expressions that return a value. Learning how to create your own methods is the basis for almost all programming you'll do in Ruby. The Ruby Methods badge teaches you all about creating and using methods.

A loop is a series of statements that can be repeated several times. The Ruby language has several different kinds of loops available when writing programs. The loops badge walks you through creating loops and using different kinds of loops in your code.

Blocks are a special kind of syntax in Ruby. A block is a way of grouping statements together that is executed when Ruby encounters the method. The Ruby Blocks badge teaches you how to create, use, and work with blocks in your Ruby programs.

Benchmarking

In this lesson, we've written a simple benchmarking class. Try expanding upon that by asking the user how many iterations they would like to run and then sorting the output from the quickest to slowest finding.

Procs & Lambdas are blocks of code that are assigned to variables. In this way, procs and lambdas can be passed around to different methods and the scope can change. The Procs & Lambdas badge teaches you how to create and work with procs and lambdas as well as the differences between them.

Passing Functions Around

Modules serve as containers for data, classes, methods, or even other modules. Modules are very useful for sharing behavior between your classes and are frequently used for namespacing classes and constants in your programs.

Put it all Together

Now that we have many of the basic classes of Ruby in our toolbox, try writing a program that uses modules and classes to create a movie class. Each movie should have a title and rating. Finally, implement comparison of movies using the Comparable module.

The Ruby standard library is packaged with every Ruby installation. The standard library contains modules and classes that are commonly used for writing programs. This includes functionality for testing, configuration, option parsing, benchmarking, and more. The Ruby Standard Library badge walks through some of the modules and classes available in the standard library.

Automated testing is the process of writing code that tests different behavior of your programs. The Ruby standard library includes a library called MiniTest which can be used to write automated tests. The Ruby Testing Badge walks through using the MiniTest library and introduces the process of test driven development.

Instructor

When not fighting web crime, Jason Seifer is a teacher at Treehouse. He's passionate about the web and programming. You can find Jason on Twitter at @jseifer and on his personal blog at jasonseifer.com.