Ruby Essential Training: 2 Classes and Modules

Ruby Essential Training: 2 Classes and Modules

English | MP4 | AVC 1280Ă—720 | AAC 48KHz 2ch | 3h 01m | 372 MB

Once you understand the basics of Ruby, you can start creating custom classes and modules. These programming constructs make it easier to organize and maintain code and extend your applications with new features. In Ruby Essential Training 2, instructor Kevin Skoglund teaches the fundamentals of object-oriented programming with classes and modules. Learn how to define classes, the templates for creating object instances with their own unique behaviors and attributes. Discover how to use inheritance to share attributes and methods between a superclass and subclasses—and to extend or override them when necessary. Then find out how to use modules as namespaces, to prevent conflicts with other code, or as mixins, to share functionality between classes. The course includes step-by-step demonstrations, complete with examples and challenges that allow you to practice your new Ruby skills along the way.

Topics include:

  • Defining a custom class
  • Working with instances of a class
  • Class and instance attributes and methods
  • Class inheritance
  • Working with dates and times
  • Using modules as namespaces and mixins
  • Raising and handling exceptions
Table of Contents

Introduction
1 Learn to use custom classes in Ruby
2 What you need to know
3 Get the most out of the exercise files

Classes
4 Define a class
5 Instances
6 Attributes
7 Reader writer methods
8 Attribute methods
9 Method access control
10 Initialize method
11 Challenge – Dice
12 Solution – Dice

Class Attributes and Methods
13 Class methods
14 Class attributes
15 Class reader writer methods
16 Challenge – Radio
17 Solution – Radio

Inheritance
18 Class inheritance
19 Override and extend
20 Access the superclass
21 Challenge – Secure radio
22 Solution – Secure radio

Dates and Times
23 Time
24 Date
25 DateTime
26 Challenge – Birth date analysis
27 Solution – Birth date analysis

Modules
28 Namespacing
29 Mixins
30 Load require include
31 Challenge – To-do list
32 Solution – To-do list

Exceptions
33 Handle exceptions
34 Handle specific exceptions
35 Exception methods
36 Raise exceptions
37 Custom exceptions
38 Challenge – Custom exceptions

Conclusion
39 Next steps