Prev | Current Page 181 | Next

David Berube

"Practical Reporting with Ruby and Rails"

You cannot simply escape a list of strings with their
backslashed counterparts, since they aren??™t all simple backslash substitutions, and substitutions
contain earlier ones; the substitution for the backslash character contains
dollar signs, for example. You therefore need to loop through the string using just a
single regular expression, which you create using a character class consisting of each of
the special characters, and you pass it to the gsub method. However, you don??™t pass a
replacement string; instead, you pass a block, which lets you look up the appropriate
substitution for each of the special characters.
Next, you start a string buffer, which will contain your document before it??™s written to
a file:
CHAPTER 6 n TRACKING AUCTIONS WITH EBAY 128
temporary_latex_file='average_price_report.tex' # This file name will also control
# the output file name. The
# file will be named
# average_price_report.pdf.
latex_source='
\documentclass{article}
\begin{document}
\huge % Switch to huge size and
\textbf{Competitor Average Price Report} % print a header at the
% top of the page.


Pages:
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
Mobb Deep kreskowka Modest Mouse Massive Attack Ben Moody