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

Treehouse

Ruby Objects and Classes Course (How To)

via Treehouse

Overview

Ruby is known as an "Object Oriented" programming language. But what does object oriented mean? In this course, we'll cover the basics of Ruby Classes. We'll learn what classes are, how they are used, and how to write our own.

What you'll learn

  • Ruby Objects
  • Ruby Classes
  • Scope
  • Methods

Syllabus

Ruby Objects and Classes

Objects and Classes are the blueprints and building blocks of the Ruby language. In this stage, we'll learn what classes are, where objects come from, and write our own class.

Chevron 8 steps
  • Ruby Classes

    1:27

  • Ruby Classes

    3 questions

  • Instantiation

    3:49

  • Instantiation

    2 objectives

  • Ruby Objects

    3:42

  • Asking Objects Questions

    1 objective

  • Creating a Class

    3:56

  • Creating and Instantiating a Class

    3 objectives

Variables and Methods

Classes and objects become much more useful when we keep our program's logic in them. In this stage, we'll learn how to use variables in our classes and where variables can and can't be used. We'll also learn to write methods in our classes, which make them more robust.

Chevron 12 steps
  • Variables

    4:48

  • Variables and Methods

    4 objectives

  • Attribute Readers

    1:46

  • Attribute Readers

    1 objective

  • Attribute Writers and Accessors

    5:20

  • Attribute Writers and Accessors

    2 objectives

  • Methods

    3:31

  • Methods

    1 objective

  • Instance Variables and Local Variables

    4:54

  • Instance Variables and Local Variables

    4 questions

  • The to_s method

    2:16

  • The to_s Method

    1 objective

Build a Bank Account Class

Using our knowledge of writing classes, we're going to create a simple bank account class. The class will keep track of whom it belongs to as well as the account's transactions and its ongoing balance.

Chevron 8 steps
  • Part 1: Create the Class

    4:01

  • Create a BankAccount Class

    3 objectives

  • Part 2: Transactions, credits, and debits

    5:06

  • Adding Transactions

    2 objectives

  • Part 3: Keeping Our Balance

    4:20

  • Implement the balance Method

    1 objective

  • Part 4: Printing the register

    6:26

  • Printing The BankAccount

    1 objective

  • Extra Credit

    Try using the inject method to calculate the bank account balance.

Reviews

Start your review of Ruby Objects and Classes 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.