Chapter 15. Ruby and Data Formats
This is something of a "catch-all" chapter. Much of this material could have been placed elsewhere. The material is not all of equal importance or difficulty, but it is all important and needs to be covered somewhere.
It is a fact of life in computing that when information becomes complex enough, it always evolves its own "minilanguage" in which that information is best expressed. More often, it evolves multiple such minilanguages. We call these file formats or data formats.
Any of us could name hundreds of examples of file formats. There are image formats such as JPG, GIF, and PNG; document formats such as RTF and PDF; "universal" formats such as comma-separated, XML, or YAML; and countless thousands of proprietary data formats, many of which are variations on the fixed-column data storage so common in ancient times (meaning the 1960s).
One of the simplest, most common of data formats is plain text. Even if a file is simple text, however, it may have a structure imposed on it (hence the current popularity of XML). Other formats may be pure binary or some mixture of text and binary. So there are potentially "hierarchies" of formats just as the ISO networking model viewed information differently at different levels of networking.
No matter what format data is stored in, sooner or later we want to read it, parse it, and write it again. This chapter covers a few common file formats; there is no way to cover all of the common ones in a single book, however. If you want to parse such formats as vCard, iCal, or hundreds of others, you will have to do a search for the appropriate libraries (or you may have to write your own).