Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Ruby Modules Course (How To)

via Treehouse

Overview

Modules are an extremely powerful utility when coding in Ruby. Modules allow you to add behavior to classes, hold constants, add namespaces, and more.

What you'll learn

  • Modules
  • Methods
  • Class Methods
  • Include and Extend
  • Magic Methods in Ruby

Syllabus

Ruby Module Basics

In this stage, is to introduce the basics of working with modules in Ruby as well as give the students brief exposure to more advanced topics with modules.

Chevron 6 steps
  • What Are Modules?

    1:47

  • What Are Modules?

    4 questions

  • Write a Simple Module

    3:35

  • Write a Simple Module

    1 objective

  • Namespaces

    4:58

  • Namespaces

    2 objectives

Ruby Core Modules

In this stage, we'll learn about some of the modules that are included as part of the Ruby core distribution.

Chevron 6 steps
  • Comparable

    5:14

  • Comparable

    2 objectives

  • Math

    4:05

  • Math

    3 objectives

  • Enumerable

    7:49

  • Enumerable

    2 objectives

Include and Extend

Ruby Modules give you two different ways to augment behavior: Include and Extend. In this stage, we'll learn about the differences between the two as well as how to use them when creating our own modules.

Chevron 6 steps
  • Include

    3:05

  • Include

    2 objectives

  • Being Included

    5:42

  • Being Included

    1 objective

  • Extend

    6:17

  • Extend

    1 objective

Store Inventory Using Modules

Now that we now how modules work, we’re going to write a simple program that simulates keeping inventory at a small retail store. The store sells shirts, pants, and accessories. We’re going to put everything together using modules, include, extend, and friends. Make sure to follow along using Workspaces.

Chevron 10 steps
  • Class Set Up

    3:37

  • Class Set Up

    2 objectives

  • Stock Counts

    3:10

  • Stock Counts

    2 objectives

  • Extend and Include

    4:14

  • Extend an Include

    1 objective

  • Creating an In Stock Report

    6:24

  • Debugging Errors

    1 objective

  • Refactoring and Namespaces

    4:30

  • Namespacing

    1 objective

Reviews

Start your review of Ruby Modules Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.