Recipe 12.1. Thumbnailing Images
Credit: Antonio Cangiano
Problem
Given an image, you want to create a smaller image to serve as a thumbnail.
Solution
Use RMagick, available from the rmagick or rmagick-win32 gems. Its Magick module ...
Recipe 12.2. Adding Text to an Image
Credit: Antonio Cangiano
Problem
You want to add some text to an imageperhaps a caption or a
copyright statement.
Solution
Create an RMagick Draw object and call its annotate method, passing i...
Recipe 12.3. Converting One Image Format to Another
Credit: Antonio Cangiano
Problem
You want to convert an image to a different format.
Solution
With RMagick, you can just read in the file and write it out with a different extension. Th...
Recipe 12.4. Graphing Data
Problem
You want to convert a bunch of data into a graph; usually a line chart, bar chart, or pie chart.
Solution
Use the
Gruff library, written by Geoffrey Grosenbach. Install the
gruff gem and build...
Recipe 12.5. Adding Graphical Context with Sparklines
Problem
You want to display a small bit of statistical contexta trend or a set of percentagesin the middle of a piece of text, without breaking up the flow of the text.
Solution
I...
Recipe 12.6. Strongly Encrypting Data
Problem
You want to encrypt some data: to keep it private, or to keep it safe when sent through an insecure medium like email.
Solution
There are at least two good symmetric-key cryptography libr...
Recipe 12.7. Parsing Comma-Separated Data
Problem
You have a plain-text string in a comma-delimited format. You need to parse this string, either to build a data structure or to perform some operation on the data and write it back out.
...
Recipe 12.8. Parsing Not-Quite-Comma-Separated Data
Problem
You need to parse a plain-
text string or file that's in a format similar to commadelimited format, but its delimiters are some
strings other than commas and newlines.
...
Recipe 12.9. Generating and Parsing Excel Spreadsheets
Problem
Your program needs to parse data from Excel
spreadsheets, or generate new
Excel spreadsheets.
Solution
To generate Excel files, use the spreadsheet librar...
Recipe 12.10. Compressing and Archiving Files with Gzip and Tar
Problem
You want to write compressed data to a file to save space, or uncompress the contents of a compressed file. If you're
compressing data, you might wan...
Recipe 12.11. Reading and Writing ZIP Files
Problem
You want to create or examine a ZIP archive from within Ruby code.
Solution
Use the
rubyzip gem. Its Zip module gives you several ways of putting files into ZIP archives, and taking t...
Recipe 12.12. Reading and Writing Configuration Files
Problem
You want to store your application's
configuration on disk, in a format parseable by Ruby but easily editable by someone with a text editor.
Solution
Put your
config...
Recipe 12.13. Generating PDF Files
Problem
You want to create a text or graphical document as a
PDF, where you have complete control over the layout.
Solution
Use Austin Zeigler's
PDF::Writer library, available as the pdf-...
С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.