
- Ruby
- Beginner
About this Course
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
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.
8 stepsVariables 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.
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.
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.
Teacher
-
Jason Seifer
Jason helped launch Treehouse and spent 4 years teaching here before returning to Rails development full time.