Ruby Essential Training Part 3: Files, Formats, Templates

Ruby Essential Training Part 3: Files, Formats, Templates

2h 27mBeginner2019-02-07

Authors

Kevin Skoglund

Kevin Skoglund

Founder of NovaFabrica

Course details

Discover how to use Ruby code to interact with the file system. With Ruby, you can read and write to config files and logs, automate tasks like mail merge, and find and organize files without ever leaving your code editor. In this course, the third in the Ruby Essential Training series, Kevin Skoglund reviews the basic techniques for working with files and directories. Learn to find existing files and directories and to create new ones. Discover different techniques for reading and writing data to files. Then learn how to import and export data in popular formats and how to use Embedded Ruby (ERB) to bind dynamic values into reusable file templates. Each lesson is filled with practical examples, and programming challenges allow you to practice your new skills as you progress through the course.

Learning objectives
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

Skills covered

RubyEssential TrainingProgramming LanguagesOpen SourceSoftware Development

Concepts

Introduction

  • Learn the essentials of working with files in Ruby
  • What you need to know

The File System

  • Input output basics
  • File system basics
  • Types of file paths
  • File permissions

Work with Files

  • Access files
  • Write to files
  • Read from files
  • File pointer
  • Read or write an entire file
  • Rename, delete, copy
  • Examine file details
  • Challenge - List maker
  • Solution - List maker

Work with Directories

  • Create directories
  • Change directories
  • Entries
  • Glob
  • Challenge - Multi-list maker
  • Solution - Multi-list maker

Common Data Formats

  • CSV
  • CSV to hashes
  • YAML
  • JSON
  • XML

ERB Templating

  • Embed Ruby
  • Binding
  • Template files
  • Challenge - Mail merge
  • Solution - Mail merge

Conclusion

  • Next steps
80,000 Toman