Prev | Current Page 232 | Next

David Berube

"Practical Reporting with Ruby and Rails"


Note that your temporary variables are created outside the open block. This is so that
they are scoped appropriately, as opposed to being local variables of the block, and can
be accessed outside the block.
Additionally, you might notice that the call to ps2pdf is preceded by two dashes. The
first dash tells the program that instead of reading from a file, it should read its input
from STDIN, which is normally the keyboard but, in this case, is your program.
Finally, note that the calls have the flags wb+. In fact, so do your previous two open
calls, which open the pipes to the html2ps and ps2pdf utilities. This is a three-part flag:
??? The w means write, so it can be written to.
??? The + means that you can read from it as well.
??? The b affects only calls on Windows, and means it??™s binary mode. This affects the
way \n characters are handled. Without the b flag, \n is transparently converted
into \r\n, and since binary files often contain \n elements, they can be corrupted
easily. Note that, strictly speaking, the first call to html2ps might be okay without
the b flag, but there is no point in taking chances.


Pages:
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
AC/DC Porównywarka poker wygrać ręcznik wirtualne nieruchomości