Join Kevin Skoglund for an in-depth discussion in this video Solution: Radio, part of Ruby: Classes and Modules.
(chime rings)…- [Instructor] In this movie, I'm going to show you…the solution that I came up for the Radio Challenge.…So I took the class Radio and I got a couple…of attribute readers here.…One for volume, one for freq, or frequency,…and one for band.…Now I just made those reader methods.…They're not attribute accessor or attribute writer methods.…I'm only able to read them.…So that gives me a built-in method…to read back those instance variables.…Underneath that you can see I've got…some class variables set.…
And I'm setting one for the range of FM frequencies…and also a default FM frequency.…One for the AM frequencies and one for the…default AM frequency.…Those will give me some reference points…that I can work with.…They define sort of how the class should work in general,…regardless of how a specific instance might work.…Then, I've got a couple of the factory pattern here…that I'm using class methods for self.am and self.fm.…Those are just going to make a new radio instance,…with the band being set to either AM or FM.…
- 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
Skill Level Beginner
2. Class Attributes and Methods
4. Dates and Times
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.