Join Kevin Skoglund for an in-depth discussion in this video Accessing the restaurant file, part of Ruby Essential Training.
- View Offline
- Exercise Files
Now that we have our Guide class successfully interacting with our Restaurant class, …we need to give our Restaurant class the methods it needs to interact…with the file system.…We haven't written those methods yet.…That's what we will do in this movie.…Now just as a quick review. Remember in the Guide class we are calling a couple…different of methods on the Restaurant class.…The first is filepath equals, which is no problem, we have already created that.…We also have file_exists with a question mark after it.…We haven't written that method yet, and Restaurant create file.…And notice that I am using them as part of a conditional statement, if then.…So we will also want to be mindful of what return value we give for each of these.…
We want to make sure we return True or False to let it know whether it…succeeded or failed.…So let's jump over to the Restaurant class.…Here is our file_exists method, and let's just make a if statement, if something--…we'll come back to it, return true else return false.…
- 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.