Join Kevin Skoglund for an in-depth discussion in this video Attribute methods, part of Ruby Essential Training.
We've seen how we can use reader, writer methods in order to access our attributes.…We saw how we could even use Ruby's syntactic sugar to make the process a little easier.…But one thing that's striking is you may be thinking, well, what if I have a…large class that has lots of attributes?…Are you telling me that I have to go through and write a reader and a writer…attribute for each and every one of those attributes.…Well fortunately, the answer is no, you don't have to do that over and over again.…Ruby provides a very nice shortcut, because this is done so often that we can…just simply use an attribute method.…
These are also frequently called attr methods or attr_* methods, and that's…because they all begin with attr_ and that * serves as a wild card for…everything that comes after it.…The three methods that we're going to be looking at are, attribute reader,…attribute writer, and attribute accessor.…Each one of them is actually a method that we're putting into our class.…When that method gets called, it takes a symbol that we provide after it and…
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- 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.