Example: Generating a Purchase Ledger
At the start of the chapter, we saw an example of something that we might write a template for: a purchase ledger for a fictional bar:
| The Bistro Illegal |
| Sector RT 74 |
| Lazgar Beta |
| |
| Purchase ledger, October 2014 |
| |
| Generated: 4 October 2014, 12:49pm |
| |
| Product Units Price |
| |
| Ol' Janx Spirit 282 $27,918.00 |
| Eau de Santraginus V 300 $600.00 |
| Arcturan Mega-Gin 150 $7,500.00 |
| Fallian Marsh Gas 1,000 $2,000.00 |
| Qalactin Hypermint Extract 25 $500.00 |
| Algolian Suntiger, teeth of 300 $30,000.00 |
| Zamphuor 3 $120.00 |
| Olives 200 $24.00 |
| |
| Total $68,662.00 |
Let’s write an example ERB template for this type of file. We won’t worry about where the data is coming from just yet; we’ll write our idealized template and ...
Get Text Processing with Ruby now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.