Join Kevin Skoglund for an in-depth discussion in this video Access files, part of Ruby: Files, Formats, Templates.
- [Instructor] In this chapter,…we are going to learn to work with files in Ruby.…And we're going to start by learning how to access those files.…We can access files in Ruby two different ways.…The first is by using File.new,…and the second is using File.open.…And there are some differences that we need to understand.…File.new, as you might expect,…creates a new instance of the File class,…just like when we're creating any new instance from a class.…We provide two arguments to it,…the first is the path to the file,…that can be an absolute path or a relative path.…
And then the second is the file mode,…and we'll talk more about file mode in a minute.…You can see here I've got a simple string with a w…that puts it in write mode.…So this is going to allow us to write to the file.…You'll notice that I'm taking that instance…and assigning it to the variable file.…Then I can use that variable and work with the file.…I can write to it, I can read to it,…I can query it and ask questions about it,…and at the end, I want to close the file.…
- File system basics
- Writing to and reading from files
- Renaming, deleting, and copying files
- Creating and editing directories
- Working with common data formats
- ERB templating
Skill Level Beginner
Ruby on Rails 5 Essential Trainingwith Kevin Skoglund10h 21m Beginner
1. The File System
2. Work with Files
3. Work with Directories
4. Common Data Formats
5. ERB Templating
- 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.