ypdf-writer 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog +134 -0
  3. data/LICENCE +131 -0
  4. data/bin/techbook +24 -0
  5. data/demo/chunkybacon.rb +40 -0
  6. data/demo/code.rb +71 -0
  7. data/demo/colornames.rb +47 -0
  8. data/demo/demo.rb +73 -0
  9. data/demo/gettysburg.rb +66 -0
  10. data/demo/hello.rb +26 -0
  11. data/demo/individual-i.rb +89 -0
  12. data/demo/pac.rb +70 -0
  13. data/demo/qr-language.rb +580 -0
  14. data/demo/qr-library.rb +380 -0
  15. data/images/bluesmoke.jpg +0 -0
  16. data/images/chunkybacon.jpg +0 -0
  17. data/images/chunkybacon.png +0 -0
  18. data/lib/pdf/charts.rb +13 -0
  19. data/lib/pdf/charts/stddev.rb +431 -0
  20. data/lib/pdf/core_ext/mutex.rb +12 -0
  21. data/lib/pdf/math.rb +108 -0
  22. data/lib/pdf/quickref.rb +333 -0
  23. data/lib/pdf/simpletable.rb +952 -0
  24. data/lib/pdf/techbook.rb +907 -0
  25. data/lib/pdf/writer.rb +2760 -0
  26. data/lib/pdf/writer/arc4.rb +63 -0
  27. data/lib/pdf/writer/fontmetrics.rb +203 -0
  28. data/lib/pdf/writer/fonts/Courier-Bold.afm +342 -0
  29. data/lib/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
  30. data/lib/pdf/writer/fonts/Courier-Oblique.afm +342 -0
  31. data/lib/pdf/writer/fonts/Courier.afm +342 -0
  32. data/lib/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
  33. data/lib/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
  34. data/lib/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
  35. data/lib/pdf/writer/fonts/Helvetica.afm +3051 -0
  36. data/lib/pdf/writer/fonts/MustRead.html +19 -0
  37. data/lib/pdf/writer/fonts/Symbol.afm +213 -0
  38. data/lib/pdf/writer/fonts/Times-Bold.afm +2588 -0
  39. data/lib/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
  40. data/lib/pdf/writer/fonts/Times-Italic.afm +2667 -0
  41. data/lib/pdf/writer/fonts/Times-Roman.afm +2419 -0
  42. data/lib/pdf/writer/fonts/ZapfDingbats.afm +225 -0
  43. data/lib/pdf/writer/graphics.rb +813 -0
  44. data/lib/pdf/writer/graphics/imageinfo.rb +366 -0
  45. data/lib/pdf/writer/lang.rb +43 -0
  46. data/lib/pdf/writer/lang/en.rb +99 -0
  47. data/lib/pdf/writer/object.rb +23 -0
  48. data/lib/pdf/writer/object/action.rb +35 -0
  49. data/lib/pdf/writer/object/annotation.rb +42 -0
  50. data/lib/pdf/writer/object/catalog.rb +39 -0
  51. data/lib/pdf/writer/object/contents.rb +70 -0
  52. data/lib/pdf/writer/object/destination.rb +40 -0
  53. data/lib/pdf/writer/object/encryption.rb +53 -0
  54. data/lib/pdf/writer/object/font.rb +72 -0
  55. data/lib/pdf/writer/object/fontdescriptor.rb +34 -0
  56. data/lib/pdf/writer/object/fontencoding.rb +40 -0
  57. data/lib/pdf/writer/object/image.rb +305 -0
  58. data/lib/pdf/writer/object/info.rb +51 -0
  59. data/lib/pdf/writer/object/outline.rb +30 -0
  60. data/lib/pdf/writer/object/outlines.rb +30 -0
  61. data/lib/pdf/writer/object/page.rb +195 -0
  62. data/lib/pdf/writer/object/pages.rb +115 -0
  63. data/lib/pdf/writer/object/procset.rb +46 -0
  64. data/lib/pdf/writer/object/viewerpreferences.rb +74 -0
  65. data/lib/pdf/writer/ohash.rb +58 -0
  66. data/lib/pdf/writer/oreader.rb +25 -0
  67. data/lib/pdf/writer/state.rb +48 -0
  68. data/lib/pdf/writer/strokestyle.rb +138 -0
  69. data/manual.pwd +5965 -0
  70. data/readme.md +36 -0
  71. metadata +151 -0
@@ -0,0 +1,380 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # This Quick Reference card program is copyright 2003�2005 Ryan
7
+ # Davis and is licensed under the Creative Commons Attribution
8
+ # NonCommercial
9
+ # ShareAlike[http://creativecommons.org/licenses/by-nc-sa/2.0/] licence.
10
+ #
11
+ # See LICENCE in the main distribution for full licensing information.
12
+ #
13
+ # $Id$
14
+ #++
15
+ begin
16
+ require 'pdf/writer'
17
+ rescue LoadError => le
18
+ if le.message =~ %r{pdf/writer$}
19
+ $LOAD_PATH.unshift("../lib")
20
+ require 'pdf/writer'
21
+ else
22
+ raise
23
+ end
24
+ end
25
+
26
+ require 'pdf/quickref'
27
+
28
+ if ARGV[0].nil?
29
+ paper = "LETTER"
30
+ else
31
+ if PDF::Writer::PAGE_SIZES.has_key?(ARGV[0])
32
+ paper = ARGV[0]
33
+ else
34
+ puts <<-EOS
35
+ usage: #{File.basename($0)} [paper-size]
36
+
37
+ paper-size must be one of the standard PDF::Writer page sizes.
38
+ Default paper-size is LETTER.
39
+ EOS
40
+ exit 0
41
+ end
42
+ end
43
+
44
+ PDF::QuickRef.make(paper, 3) do
45
+ pdf.compressed = true
46
+ pdf.info.author = "Ryan Davis"
47
+ pdf.info.title = "Ruby Library Quick Reference"
48
+ pdf.info.subject = "The Ruby Standard Library"
49
+
50
+ self.title_font_size = 13
51
+ self.h1_font_size = 10
52
+ self.h2_font_size = 8
53
+ self.h3_font_size = 7
54
+ self.h4_font_size = 6
55
+ self.body_font_size = 5
56
+
57
+ enc = {
58
+ :encoding => 'WinAnsiEncoding',
59
+ :differences => {
60
+ 148 => "copyright",
61
+ }
62
+ }
63
+ self.title_font_encoding = enc
64
+ self.heading_font_encoding = enc
65
+ self.body_font_encoding = enc
66
+ self.code_font_encoding = enc
67
+
68
+ title "Ruby Standard Library QuickRef"
69
+ h1 "Class Hierarchy"
70
+ pairs <<-'EOS'
71
+ Object The parent object class. Includes <b>Kernel</b>.
72
+ Array Ordered integer-indexed collection of any object. Includes <b>Enumerable</b>.
73
+ Hash An unordered associative collection; keys may be any object. Includes <b>Enumerable</b>.
74
+ String Holds and manipulates an arbitrary sequence of bytes, typically representing characters. Includes <b>Comparable</b> and <b>Enumerable</b>.
75
+ Symbol Names in the ruby interpreter.
76
+ IO Base input/output class for Ruby. Includes <b>Enumerable</b>.
77
+ File An abstraction of a file object for IO purposes.
78
+ File::Stat Encapsulates File status information. Includes <b>Comparable</b>.
79
+ Continuation Holds a return address and execution context, allowing for nonlocal returns to the execution context.
80
+ Exception The root exception class. StandardError The parent of exceptions that can be rescued without an exception specification. Children are: LocalJumpError, SystemStackError, ZeroDivisionError, RangeError (FloatDomainError), SecurityError, ThreadError, IOError (EOFError), ArgumentError, IndexError, RuntimeError, TypeError, SystemCallError (Errno::*), and RegexpError.
81
+ SignalException An exception raised from an OS signal.
82
+ Interrupt An interrupt exception.
83
+ NoMemoryError The interpreter is out of memory.
84
+ ScriptError Various script errors. Children are: LoadError, NameError, SyntaxError, and NotImplementedError.
85
+ SystemExit This exception is raised when Kernel#exit is called.
86
+ Proc Blocks of code bound to a set of local variables.
87
+ Numeric The base class that numbers are based on. Includes <b>Comparable</b>.
88
+ Float Real numbers using the native architecture�s double-precision floating point representation. Includes <b>Precision</b>
89
+ Integer The abstract class for the two whole number classes, Bignum and Fixnum. Includes <b>Precision</b>.
90
+ Bignum Holds large integers outside of Fixnum�s range. Autoconverts on overflow and underflow.
91
+ Fixnum Integer values that can fit in a native word (less one bit). Includes <b>Precision</b>.
92
+ Regexp Regular expression objects.
93
+ Module A collection of methods and constants that may be used as a namespace or mixed in to objects, other modules, or classes.
94
+ Class The base class for object classes.
95
+ Thread Encapsulates Ruby�s green threads.
96
+ ThreadGroup Allows the tracking of multiple threads as a group.
97
+ Method An instance of a method bound to a particular object. Calls are against that object.
98
+ UnboundMethod An method unassociated with an object, but can be bound against an object.
99
+ Struct A convenient way to bundle a number of attributes together, using accessor methods, without having to write an explicit class.
100
+ Time A class for encapsulating the concept of a moment in Time.
101
+ Dir Directory streams representing directories in the underlying file system.
102
+ Binding Encapsulate the execution context at some particular place in the code and retain this context for future use.
103
+ Range Represents an interval (a set of values with a start and an end).
104
+ MatchData A match for a regular expression. Returned by Regexp#match.
105
+ TrueClass The class of the global value <b>true</b>.
106
+ FalseClass The class of the global value <b>false</b>.
107
+ NilClass The class of the global value <b>nil</b>.
108
+ EOS
109
+
110
+ h1 "Modules"
111
+ pairs <<-'EOS'
112
+ Comparable Used by classes whose objects may be ordered. Requires the definition of the <b>&lt;=&gt;</b> operator for useful.
113
+ Enumerable Provides collection classes with traversal, search, and sort methods. Must provide <b>each</b>; for some methods, contained objects must implement <b>&lt;=&gt;</b>.
114
+ Errno Errno is created by the Ruby runtime to map operating system errors to Ruby classes. Each error will be a subclass of SystemCallError in the Errno namespace.
115
+ FileTest Implements file test operations similar to those used in File::Stat. It exists as a standalone module, and its methods are also insinuated into the File class.
116
+ GC Provides an interface to Ruby�s mark and sweep garbage collection mechanism.
117
+ Kernel Implements a whole host of useful methods that don�t quite belong to any object.
118
+ Marshal Converts Ruby objects into a byte stream, allowing them to be stored outside the currently active script. This data may subsequently be read and the original objects reconstituted.
119
+ Math Contains module functions for basic trigonometric and transcendental functions.
120
+ ObjectSpace Contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator.
121
+ Precision A mixin for concrete numeric classes with precision; the fineness of approximation of a real number.
122
+ Process A collection of methods used to manipulate processes.
123
+ EOS
124
+
125
+ h1 "Standard Library"
126
+ pairs <<-'EOS'
127
+ English Include to allow for alternate, less-cryptic global variables names.
128
+ Env, importenv Imports environment variables as global variables.
129
+ Win32API Access to the Win32API directly.
130
+ abbrev Provides Abbrev::abbrev, to calculate the set of unique abbreviations for a given set of strings.
131
+ base64 Provides conversion to and from base64 in the Base64 module. Top-level usage of base64 conversions is deprecated.
132
+ benchmark Provides methods for benchmarking Ruby code.
133
+ bigdecimal Large number arbitrary precision floating point support. Analagous to Bignum.
134
+ bigdecimal/jacobian Computes Jacobian matrix of f at x.
135
+ bigdecimal/ludcmp Provides LUSolve#ludecomp and #lusolve.
136
+ bigdecimal/math Provides BigMath module.
137
+ bigdecimal/newton Solves nonlinear algebraic equation system f = 0 by Newton�s method.
138
+ bigdecimal/nlsolve Solving nonlinear algebraic equation system.
139
+ bigdecimal/util BigDecimal utilities.
140
+ cgi-lib CGI support library implemented as a delegator. Deprecated.
141
+ cgi CGI support library.
142
+ cgi/session Implements session support for CGI.
143
+ cgi/session/pstore Implements session support for CGI using PStore.
144
+ complex Implements the Complex class for complex numbers.
145
+ csv CSV class for generating and parsing delimited data.
146
+ date Provides Date and DateTime classes.
147
+ date/format Provides date formatting utilities.
148
+ delegate Delegation pattern; provides DelegateClass and SimpleDelegator.
149
+ dl Dynamic definition of Ruby interfaces to dynamically loaded libraries. Also uses dl/import, dl/struct, dl/types, and dl/win32.
150
+ drb �Distributed Ruby�. Has several other modules (drb/*).
151
+ e2mmap Exception2MessageMapper module.
152
+ erb Tiny �eRuby� embedded Ruby class.
153
+ eregex Proof of concept extensions to regular expressions.
154
+ fileutils Namespace for file utility methods: copying, moving, deleting, etc.
155
+ finalize Finalizer wrapper methods.
156
+ find Find module to for top-down traversal (and processing) of a set of file paths.
157
+ forwardable Simple delegation of individual methods.
158
+ ftools Extra tools for the file class. Deprecated, use fileutils.
159
+ generator Convert an internal iterator to an external one.
160
+ getoptlong Parses command-line options like the GNU getopt_long().
161
+ getopts Obsolete option parser. getoptlong or optparse is preferred.
162
+ gserver Implements a generic server.
163
+ digest Cryptographic digest support: Digest::MD5 (digest/md5), Digest::RMD160 (digest/rmd160), Digest::SHA1 (digest/sha1), and Digest::SHA2 (digest/sha2) are all supported.
164
+ enumerator Similar to Generator, creates an external enumerator from an enumerable method on an object.
165
+ etc Provides access to user/group information. Called /etc because this information is traditionally in /etc/passwd on Unix.
166
+ fcntl File control constants in the Fcntl namespace.
167
+ nkf Network Kanji conversion filter.
168
+ racc Ruby YACC. Only the runtime may be present in some installations.
169
+ rbconfig Ruby compile-time configuration configuration constants.
170
+ sdbm Ruby interface to SDBM.
171
+ socket Socket support.
172
+ stringio StringIO support; neither a String nor an IO, but a little of both.
173
+ strscan Fast Ruby string scanner.
174
+ syck Fast YAML parser.
175
+ tcltklib Tcl/Tk support.
176
+ tktul Tk utilities.
177
+ win32ole Access to Win32�s OLE controls.
178
+ ipaddr IPAddr class to manipulate IP addresses.
179
+ jcode Helps handle Japanese (EUC/SJIS) strings.
180
+ kconv Helps with Kanji conversion between JIS, SJIS, UTF-8, and UTF-16.
181
+ logger Logger is a simple logging utility.
182
+ mailread Reads a mail file and presents it as a class.
183
+ mathn Extends Ruby with complex, rational, and matrix behaviour with additional behaviour.
184
+ matrix Implements Matrix and Vector classes.
185
+ md5 Deprecated. Use digest/md5 instead.
186
+ mkmf Used to create Makefile for extension modules. Use with <b>ruby -r mkmf extconf.rb</b>.
187
+ monitor An extensible module to monitor an object for changes.
188
+ multi-tk Support for multiple Tk interpreters.
189
+ mutex_m Allows a random object to be treated as a Mutex.
190
+ net/ftp FTP client library.
191
+ net/http HTTP client library.
192
+ net/imap IMAP client library.
193
+ net/pop POP3 client library.
194
+ net/smtp SMTP client library.
195
+ net/telnet Telnet client library.
196
+ observer An implementation of the Observer or Publish/Subscribe pattern.
197
+ open-uri A wrapper for Kernel#open to allow http:// and ftp:// URIs as arguments.
198
+ open3 Spawns a program like popen, but with stderr.
199
+ optparse Command-line option analysis. Preferred option parser in the standard library.
200
+ ostruct OpenStruct, creates a Struct-like object with arbitrary attributes.
201
+ parsearg Argument parser. Deprecated, uses getopts.
202
+ parsedate Provides a parser for dates.
203
+ pathname Represents a pathname to locate a file in a Unix filesystem. It does not represent the file, but the path name.
204
+ ping A simple implementation of a ping-like utility using Ruby�s native socket support.
205
+ pp Pretty printer for Ruby objects. Usable in place of #inspect.
206
+ prettyprint Implementation of pretty printing algorithm.
207
+ profile Ruby-based profiler. Use as <b>ruby -rprofile ...</b>.
208
+ profiler The Ruby profiler implementation.
209
+ pstore A filesystem �database� using Marshal formatting for storage.
210
+ rational Implements rational numbers for Ruby (2 / 3 is 2 / 3, not 0.66 repeating).
211
+ readbytes Adds IO#readbytes, reads fixed sized data and guarantees read data size.
212
+ remote-tk Supports control of remote Tk interpreters.
213
+ resolv-replace Replaces resolver behaviour on socket classes.
214
+ resolv A resolver library written in Ruby.
215
+ rexml/document Ruby Electric XML (REXML) parser.
216
+ rinda/rinda A Ruby implementation of the Linda distributed computing paradigm. Uses drb.
217
+ rss/* RSS 0.9 (rss/0.9), 1.0 (rss/1.0), or 2.0 (rss/2.0) interpreter.
218
+ rss/maker/* RSS 0.9 (rss/maker/0.9), 1.0 (rss/maker/1.0), or 2.0 (rss/maker/2.0) maker.
219
+ rubyunit Deprecated. Provides a wrapper for older RUnit classes to work as if they were Test::Unit classes.
220
+ scanf scanf for Ruby.
221
+ set An implementation of a Set calss for Ruby. A collection of unordered values with no duplicates.
222
+ sha1 Deprecated. Use digest/sha1 instead.
223
+ shell Provides shell-like interaction. (?)
224
+ shellwords Splits text into an array of tokens like Unix shells do.
225
+ singleton A module to implement the Singleton pattern.
226
+ soap/soap Native Ruby SOAP library. wsdl/* provides for service discovery.
227
+ sync A two-phase lock with counter.
228
+ tcltk Direct manipulation of Tcl/Tk utilities in a namespace.
229
+ tempfile Manipulates temporary files (that will be deleted when the need for them goes away).
230
+ test/unit Native unit testing library, Test::Unit.
231
+ thread Thread support classes.
232
+ thwait Thread synchronization classes.
233
+ time Extensions to the Time class to support RFC2822 and RFC2616 formats, as well as others.
234
+ timeout An execution timeout.
235
+ tk An interface to Tk.
236
+ tkextlib/* Support for various Tk extensions (ICONS, bwidtget, itcl, itk, etc.).
237
+ tmpdir Retrieve the temporary directory path.
238
+ tracer Tracing Ruby programs
239
+ tsort Support for topological sorting.
240
+ un Replacements for common Unix commands. <b>ruby -run -e cp -- ...</b>, etc.
241
+ uri Libraries for interpreting uniform resource indicators (URIs).
242
+ weakref A Weak reference class that is not garbage collected.
243
+ webrick Webserver toolkit.
244
+ win32/registry Access to the Win32 Regsitry.
245
+ win32/resolv An interface to DNS and DHCP on Win32.
246
+ xmlrpc/* Support for XML-RPC clients and servers.
247
+ xsd/* XML instance parser.
248
+ yaml YAML support.
249
+ EOS
250
+
251
+ h1 "ruby"
252
+ h2 "Command-Line Options"
253
+ pairs <<-'EOS'
254
+ -0[octal] specify record separator (\0, if no argument).
255
+ -a autosplit mode with -n or -p (splits $_ into $F).
256
+ -c check syntax only.
257
+ -Cdirectory cd to directory, before executing your script.
258
+ --copyright print the copyright and exit.
259
+ -d set debugging flags (set $DEBUG to true).
260
+ -e 'command' one line of script. Several -e�s allowed.
261
+ -F regexp split() pattern for autosplit (-a).
262
+ -h prints summary of the options.
263
+ -i[extension] edit ARGV files in place (make backup if extension supplied).
264
+ -Idirectory specify $LOAD_PATH directory (may be used more than once).
265
+ -Kkcode specifies KANJI (Japanese) code-set.
266
+ -l enable line ending processing.
267
+ -n assume �while gets(); ... end� loop around your script.
268
+ -p assume loop like -n but print line also like sed.
269
+ -rlibrary require the library, before executing your script.
270
+ -s enable some switch parsing for switches after script name.
271
+ -S look for the script using PATH environment variable.
272
+ -T[level] turn on tainting checks.
273
+ -v print version number, then turn on verbose mode.
274
+ --version print the version and exit.
275
+ -w turn warnings on for your script.
276
+ -x[directory] strip off text before #! line and perhaps cd to directory.
277
+ -X directory causes Ruby to switch to the directory.
278
+ -y turns on compiler debug mode.
279
+ EOS
280
+
281
+ h2 "Environment Variables"
282
+ pairs <<-'EOS'
283
+ DLN_LIBRARY_PATH Search path for dynamically loaded modules.
284
+ RUBYLIB Additional search paths.
285
+ RUBYLIB_PREFIX Add this prefix to each item in RUBYLIB. Windows only.
286
+ RUBYOPT Additional command line options.
287
+ RUBYPATH With -S, searches PATH, or this value for ruby programs.
288
+ RUBYSHELL Shell to use when spawning.
289
+ EOS
290
+
291
+ h1 "irb"
292
+ pre "irb [options] [script [args]]"
293
+
294
+ h2 "irb Command-Line Options"
295
+ pairs <<-'EOS'
296
+ -f Prevents the loading of ~/.irb.rc. Version 1.1 has a bug that swallows the next argument.
297
+ -m Math mode. Overrides --inspect. Requires �mathn�.
298
+ -d Sets $DEBUG to true. Same as �ruby -d ...�
299
+ -r module Loads a module. Same as �ruby -r module ...�
300
+ --inspect Turns on inspect mode. Default.
301
+ --noinspect Turns off inspect mode.
302
+ --readline Turns on readline support. Default.
303
+ --noreadline Turns off readline support.
304
+ --prompt[-mode] prompt Sets the prompt. �prompt� must be one of �default�, �xmp�, �simple�, or �inf-ruby�.
305
+ --noprompt Turns off the prompt.
306
+ --inf-ruby-mode Turns on emacs support and turns off readline.
307
+ --sample-book-mode, --simple-prompt Same as �--prompt simple�
308
+ --tracer Turns on trace mode. Version 1.1 has a fatal bug with this flag.
309
+ --back-trace-limit Sets the amount of backtrace to display in trace mode.
310
+ --context-mode Sets the context mode (0-3) for multiple contexts. Defaults to 3. Not very clear how/why they differ.
311
+ --single-irb Turns off multiple bindings (disables the irb command below), I think.
312
+ --irb_debug level Sets internal debug level. For irb only.
313
+ -v, --version Prints the version and exits.
314
+ EOS
315
+
316
+ h2 "irb commands"
317
+ body <<-'EOS'
318
+ irb accepts arbitrary Ruby commands and the special commands described
319
+ below.
320
+ EOS
321
+ pairs <<-'EOS'
322
+ irb_exit Exits the current session, or the program if there are no other sessions.
323
+ fork block forks and runs the given block.
324
+ irb_change_binding args Changes to a secified binding.
325
+ source file Loads a ruby file into the session.
326
+ irb [obj] Starts a new session, with obj as self, if specified.
327
+ conf[.key[= val]] Access the configuration of the session. May read and write single values.
328
+ jobs Lists the known sessions.
329
+ fg (session#|thread-id|obj|self) Switches to the specifed session.
330
+ kill session Kills a specified session. Session may be specified the same as �fg�.
331
+ xmp eval-string Evaluates the string and prints the string and result in a nice manner suitable for cut/paste operations. Only available with <b>require �irb/xmp�</b>.
332
+ EOS
333
+
334
+ h1 "Ruby Debugger"
335
+ pre "ruby -r debug ..."
336
+
337
+ h2 "Commands"
338
+ pairs <<-'EOS'
339
+ b[reak] [file:]line Set breakpoint at given line in file (default current file).
340
+ b[reak] [file:]name Set breakpoint at method in file.
341
+ b[reak] Display breakpoints and watchpoints.
342
+ wat[ch] expr Break when expression becomes true.
343
+ del[ete] [nnn] Delete breakpoint nnn (default all).
344
+ disp[lay] expr Display value of nnn every time debugger gets control.
345
+ disp[lay] Show current displays.
346
+ undisp[lay] [nnn] Remove display (default all).
347
+ c[ont] Continue execution.
348
+ s[tep] nnn=1 Execute next nnn lines, stepping into methods.
349
+ n[ext] nnn=1 Execute next nnn lines, stepping over methods.
350
+ fi[nish] Finish execution of the current function.
351
+ q[uit] Exit the debugger.
352
+ w[here] Display current stack frame.
353
+ f[rame] Synonym for where.
354
+ l[ist] [start--end] List source lines from start to end.
355
+ up nnn=1 Move up nnn levels in the stack frame.
356
+ down nnn=1 Move down nnn levels in the stack frame.
357
+ v[ar] g[lobal] Display global variables.
358
+ v[ar] l[ocal] Display local variables.
359
+ v[ar] i[nstance] obj Display instance variables of obj.
360
+ v[ar] c[onst] Name Display constants in class or module name.
361
+ m[ethod] i[nstance] obj Display instance methods of obj.
362
+ m[ethod] Name Display instance methods of the class or module name.
363
+ th[read] l[ist] List all threads.
364
+ th[read] [c[ur[rent]]] Display status of current thread.
365
+ th[read] [c[ur[rent]]] nnn Make thread nnn current and stop it.
366
+ th[read] stop nnn Make thread nnn current and stop it.
367
+ th[read] resume nnn Resume thread nnn.
368
+ [p] expr Evaluate expr in the current context. expr may include assignment to variables and method invocations.
369
+ empty A null command repeats the last command.
370
+ EOS
371
+
372
+ x = pdf.absolute_right_margin + pdf.font_height(5)
373
+ y = pdf.absolute_bottom_margin
374
+ memo = %Q(Copyright � 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the <c:alink uri="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike</c:alink> Licence. The original HTML version is at <c:alink uri="http://www.zenspider.com/Languages/Ruby/QuickRef.html">Zen Spider</c:alink>. Generated by <c:alink uri="http://rubyforge.org/projects/ruby-pdf/">PDF::Writer</c:alink> #{PDF::Writer::VERSION} and PDF::QuickRef #{PDF::QuickRef::VERSION}.)
375
+ pdf.add_text(x, y, memo, 5, 90)
376
+ x = pdf.absolute_right_margin - 32
377
+ y = pdf.absolute_bottom_margin + 24
378
+
379
+ save_as "Ruby-Library-QuickRef.pdf"
380
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id$
10
+ #++
11
+ # A namespace for charts that can be drawn on PDF::Writer canvases.
12
+ module PDF::Charts
13
+ end
@@ -0,0 +1,431 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id$
10
+ #++
11
+ require 'pdf/writer'
12
+ require 'pdf/charts'
13
+ require 'ostruct'
14
+
15
+ # Creates a standard deviation chart. This is a type of chart that is
16
+ # effective for the display of survey results or other data that can
17
+ # easily be measured in terms of the average and the standard deviation
18
+ # from that average.
19
+ #
20
+ # The scale of responses is the vertical scale; the average data points
21
+ # and standard deviation values are the horizontal scale.
22
+ class PDF::Charts::StdDev
23
+ VERSION = '1.2.0'
24
+
25
+ # A data element.
26
+ DataPoint = Struct.new(:label, :average, :stddev)
27
+
28
+ # A label for displaying the scale (vertical) of data in the dataset or
29
+ # the data set identifiers.
30
+ class Label
31
+ def initialize
32
+ yield self if block_given?
33
+ end
34
+
35
+ # The height of the label, in PDF user units. Ignored for scale
36
+ # labels.
37
+ attr_accessor :height
38
+ # The background color of the label. Ignored for scale labels.
39
+ attr_accessor :background_color
40
+ # The text color of the label.
41
+ attr_accessor :text_color
42
+ # The text size, in points, of the label.
43
+ attr_accessor :text_size
44
+ # The padding of the label. Only used for scale labels.
45
+ attr_accessor :pad
46
+ # The decimal precision of the label. Only used for scale labels.
47
+ attr_accessor :decimal_precision
48
+ end
49
+
50
+ # The scale of the dataset.
51
+ class Scale
52
+ def initialize(args = { })
53
+ @range = args[:range]
54
+ @step = args[:step]
55
+ @style = args[:style]
56
+ @show_labels = false
57
+
58
+ yield self if block_given?
59
+
60
+ raise TypeError, PDF::Lange[:charts_stddev_scale_norange] if @range.nil?
61
+ raise TypeError, PDF::Lange[:charts_stddev_scale_nostep] if @step.nil?
62
+ end
63
+
64
+ # Range of the scale. This should be a Range object.
65
+ attr_accessor :range
66
+ # The lower end of the range of the scale. The scale range may be
67
+ # modified by changing this value.
68
+ attr_accessor :first
69
+ def first #:nodoc:
70
+ @range.first
71
+ end
72
+ def first=(ff) #:nodoc:
73
+ @range = (ff..@range.last)
74
+ end
75
+ # The upper end of the range of the scale. The scale range may be
76
+ # modified by changing this value.
77
+ attr_accessor :last
78
+ def last #:nodoc:
79
+ @range.last
80
+ end
81
+ def last=(ll) #:nodoc:
82
+ @range = (@range.first..ll)
83
+ end
84
+ # Defines the step of the scale. Each step represents a vertical
85
+ # position on the chart.
86
+ attr_accessor :step
87
+ # Defines the line style for the scale on the chart. If this is unset
88
+ # (+nil+), there will be no horizontal marks across the chart for the
89
+ # steps of the scale.
90
+ attr_accessor :style
91
+ # Shows the scale labels if +true+.
92
+ attr_accessor :show_labels
93
+ # Defines the label options.
94
+ attr_accessor :label
95
+ end
96
+
97
+ # This is any line that will be drawn; this is a combination of the line
98
+ # style (which must be a PDF::Writer::StrokeStyle object) and a color.
99
+ class Marker
100
+ def initialize
101
+ yield self if block_given?
102
+ end
103
+
104
+ # The stroke style of the marker.
105
+ attr_accessor :style
106
+ # The stroke color of the marker.
107
+ attr_accessor :color
108
+ end
109
+
110
+ def initialize
111
+ @data = []
112
+
113
+ @scale = Scale.new do |scale|
114
+ scale.range = 0..6
115
+ scale.step = 1
116
+ scale.style = PDF::Writer::StrokeStyle.new(0.25)
117
+ scale.show_labels = false
118
+ scale.label = Label.new do |label|
119
+ label.text_size = 8
120
+ label.text_color = Color::RGB::Black
121
+ label.pad = 2
122
+ label.decimal_precision = 1
123
+ end
124
+ end
125
+ @leading_gap = 10
126
+ @show_labels = true
127
+ @label = Label.new do |label|
128
+ label.height = 25
129
+ label.background_color = Color::RGB::Black
130
+ label.text_color = Color::RGB::White
131
+ label.text_size = 12
132
+ end
133
+
134
+ @outer_borders = Marker.new do |marker|
135
+ marker.style = PDF::Writer::StrokeStyle.new(1.5)
136
+ marker.color = Color::RGB::Black
137
+ end
138
+ @inner_borders = nil
139
+
140
+ @dot = Marker.new do |marker|
141
+ marker.style = PDF::Writer::StrokeStyle.new(5)
142
+ marker.color = Color::RGB::Black
143
+ end
144
+ @bar = Marker.new do |marker|
145
+ marker.style = PDF::Writer::StrokeStyle.new(0.5)
146
+ marker.color = Color::RGB::Black
147
+ end
148
+ @upper_crossbar = Marker.new do |marker|
149
+ marker.style = PDF::Writer::StrokeStyle.new(1)
150
+ marker.color = Color::RGB::Black
151
+ end
152
+ @lower_crossbar = Marker.new do |marker|
153
+ marker.style = PDF::Writer::StrokeStyle.new(1)
154
+ marker.color = Color::RGB::Black
155
+ end
156
+
157
+ @height = 200
158
+ @maximum_width = 500
159
+ @datapoint_width = 35
160
+
161
+ yield self if block_given?
162
+ end
163
+
164
+ # The data used to generate the standard deviation chart. This is an
165
+ # array of DataPoint objects, each containing a +label+, an +average+,
166
+ # and the +stddev+ (standard deviation) from that average.
167
+ attr_reader :data
168
+ # The scale of the chart. All values must be within this range. This
169
+ # will be a Scale object. It defaults to a scale of 0..6 with a step of
170
+ # 1.
171
+ attr_accessor :scale
172
+
173
+ # The minimum gap between the chart and the bottom of the page, in
174
+ # PDF user units.
175
+ attr_accessor :leading_gap
176
+
177
+ # This will be +true+ if labels are to be displayed.
178
+ attr_accessor :show_labels
179
+ # The label style of the labels if they are displayed. This must be a
180
+ # PDF::Charts::StdDev::Label object.
181
+ attr_accessor :label
182
+
183
+ # The inner border style. If +nil+, no inner borders are drawn. This is
184
+ # a PDF::Charts::StdDev::Marker object.
185
+ attr_accessor :inner_borders
186
+ # The outer border style. If +nil+, no inner borders are drawn. This is
187
+ # a PDF::Charts::StdDev::Marker object.
188
+ attr_accessor :outer_borders
189
+
190
+ # The dot marker. A filled circle will be drawn with this information.
191
+ # If +nil+, the dot will not be drawn. This is a
192
+ # PDF::Charts::StdDev::Marker object.
193
+ attr_accessor :dot
194
+ # The standard deviation bar. A line will be drawn through the dot
195
+ # marker (if drawn) from the upper to lower standard deviation.
196
+ # If +nil+, the line will not be drawn. This is a
197
+ # PDF::Charts::StdDev::Marker object.
198
+ attr_accessor :bar
199
+ # The upper crossbar. A line will be drawn across the top of the
200
+ # standard deviation bar to the width of the dot marker. If #dot is
201
+ # +nil+, then the line will be twice as wide as it is thick. If +nil+,
202
+ # the upper crossbar will not be drawn. This is a
203
+ # PDF::Charts::StdDev::Marker object.
204
+ attr_accessor :upper_crossbar
205
+ # The lower crossbar. A line will be drawn across the bottom of the
206
+ # standard deviation bar to the width of the dot marker. If #dot is
207
+ # +nil+, then the line will be twice as wide as it is thick. If +nil+,
208
+ # the lower crossbar will not be drawn. This is a
209
+ # PDF::Charts::StdDev::Marker object.
210
+ attr_accessor :lower_crossbar
211
+
212
+ # The height of the chart in PDF user units. Default 200 units.
213
+ attr_accessor :height
214
+ # The maximum width of the chart in PDF user units. Default 500 units.
215
+ attr_accessor :maximum_width
216
+ # The width of a single datapoint.
217
+ attr_accessor :datapoint_width
218
+
219
+ # Draw the standard deviation chart on the supplied PDF document.
220
+ def render_on(pdf)
221
+ raise TypeError, PDF::Writer::Lang[:charts_stddev_data_empty] if @data.empty?
222
+ data = @data.dup
223
+ leftover_data = nil
224
+
225
+ loop do
226
+ # Set up the scale information.
227
+ scale = []
228
+
229
+ (@scale.first + @scale.step).step(@scale.last, @scale.step) do |ii|
230
+ scale << "%01.#{@scale.label.decimal_precision}f" % ii
231
+ end
232
+
233
+ scales = PDF::Writer::OHash.new
234
+ scale.each_with_index do |gg, ii|
235
+ scales[ii] = OpenStruct.new
236
+ scales[ii].value = gg
237
+ end
238
+
239
+ # Add information about the scales' locations to the scales
240
+ # hash. Note that the count is one smaller than it should be, so we're
241
+ # increasing it. The first scale is the bottom of the chart.
242
+ scale_count = scale.size + 1
243
+
244
+ label_height_adjuster = 0
245
+ label_height_adjuster = @label.height if @show_labels
246
+
247
+ chart_area_height = @height - label_height_adjuster
248
+ scale_height = chart_area_height / scale_count.to_f
249
+
250
+ scales.each_key do |index|
251
+ this_height = scale_height * (index + 1) + @label.height
252
+ scales[index].line_height = this_height
253
+ if @scale.show_labels
254
+ scales[index].label_height = this_height -
255
+ (@scale.label.text_size / 3.0)
256
+ end
257
+ end
258
+
259
+ # How many sections do we need in this chart, and how wide will it
260
+ # need to be?
261
+ chunk_width = @datapoint_width
262
+ num_chunks = data.size
263
+ widest_scale_label = 0
264
+
265
+ if @scale.show_labels
266
+ scales.each_value do |scale|
267
+ this_width = pdf.text_width(scale.value, @scale.label.text_size)
268
+ widest_scale_label = this_width if this_width > widest_scale_label
269
+ end
270
+ end
271
+
272
+ chart_width = chunk_width * num_chunks
273
+ total_width = chart_width + widest_scale_label + @scale.label.pad
274
+
275
+ # What happens if the projected width of the chart is too big?
276
+ # Figure out how to break the chart in pieces.
277
+ if total_width > @maximum_width
278
+ max_column_count = 0
279
+ base_width = widest_scale_label + @scale.label.pad
280
+ (1..(num_chunks + 1)).each do |ii|
281
+ if (base_width + (ii * chunk_width)) > @maximum_width
282
+ break
283
+ else
284
+ max_column_count += 1
285
+ end
286
+ end
287
+
288
+ leftover_data = data.slice!(max_column_count, -1)
289
+
290
+ num_chunks = data.size
291
+ chart_width = chunk_width * num_chunks
292
+ total_width = chart_width + widest_scale_label + @scale.label.pad
293
+ end
294
+
295
+ chart_y = pdf.y - @height + @leading_gap
296
+ chart_y += (@outer_borders.style.width * 2.0) if @outer_borders
297
+
298
+ if chart_y < pdf.bottom_margin
299
+ pdf.start_new_page
300
+ chart_y = pdf.y - @height
301
+ chart_y += (@outer_borders.style.width * 2.0) if @outer_borders
302
+ end
303
+
304
+ chart_x = pdf.absolute_x_middle - (total_width / 2.0) + widest_scale_label
305
+
306
+ # Add labels, if needed.
307
+ if @show_labels
308
+ pdf.save_state
309
+ pdf.fill_color! @label.background_color
310
+ # Draw a rectangle for each label
311
+ num_chunks.times do |ii|
312
+ this_x = chart_x + ii * chunk_width
313
+ pdf.rectangle(this_x, chart_y, chunk_width, @label.height).fill
314
+ end
315
+
316
+ # Add a border above the label rectangle.
317
+ if @outer_borders
318
+ pdf.stroke_style! @outer_borders.style
319
+ pdf.line(chart_x, chart_y + @label.height, chart_x + chart_width, chart_y + @label.height).stroke
320
+ end
321
+ pdf.fill_color! @label.text_color
322
+
323
+ data.each_with_index do |datum, ii|
324
+ label = datum.label.to_s
325
+ label_width = pdf.text_width(label, @label.text_size)
326
+ this_x = chart_x + (ii * chunk_width) + (chunk_width / 2.0) - (label_width / 2.0)
327
+ this_y = chart_y + (@label.height / 2.0) - (@label.text_size / 3.0)
328
+ pdf.add_text(this_x, this_y, label, @label.text_size)
329
+ end
330
+ pdf.restore_state
331
+ end
332
+
333
+ if @inner_borders
334
+ pdf.save_state
335
+ pdf.stroke_color! @inner_borders.color
336
+ pdf.stroke_style! @inner_borders.style
337
+ (num_chunks - 1).times do |ii|
338
+ this_x = chart_x + (ii * chunk_width) + chunk_width
339
+ pdf.line(this_x, chart_y, this_x, chart_y + @height).stroke
340
+ end
341
+ pdf.restore_state
342
+ end
343
+
344
+ pdf.save_state
345
+ if @outer_borders
346
+ pdf.stroke_color! @outer_borders.color
347
+ pdf.stroke_style! @outer_borders.style
348
+ pdf.rectangle(chart_x, chart_y, chart_width, @height).stroke
349
+ end
350
+
351
+ if @scale.style
352
+ pdf.save_state
353
+ pdf.stroke_style! @scale.style
354
+ scales.each_value do |scale|
355
+ this_y = chart_y + scale.line_height
356
+ pdf.line(chart_x, this_y, chart_x + chart_width, this_y).stroke
357
+ end
358
+ pdf.restore_state
359
+ end
360
+
361
+ if @scale.show_labels
362
+ pdf.save_state
363
+ scales.each_value do |scale|
364
+ this_y = chart_y + scale.label_height
365
+ label_width = pdf.text_width(scale.value, @scale.label.text_size)
366
+ this_x = chart_x - label_width - @scale.label.pad
367
+ pdf.fill_color! @scale.label.text_color
368
+ pdf.add_text(this_x, this_y, scale.value, @scale.label.text_size)
369
+ end
370
+ pdf.restore_state
371
+ end
372
+
373
+ data.each_with_index do |datum, ii|
374
+ avg_height = datum.average * scale_height
375
+ stddev_height = datum.stddev * scale_height
376
+ this_y = chart_y + label_height_adjuster + avg_height
377
+ this_x = chart_x + (ii * chunk_width) + (chunk_width / 2.0)
378
+ line_top_y = this_y + (stddev_height / 2.0)
379
+ line_bot_y = this_y - (stddev_height / 2.0)
380
+
381
+ # Plot the dot
382
+ if @dot
383
+ pdf.stroke_color! @dot.color
384
+ pdf.stroke_style! @dot.style
385
+ pdf.circle_at(this_x, this_y, (@dot.style.width / 2.0)).fill
386
+ end
387
+
388
+ # Plot the bar
389
+ if @bar
390
+ pdf.stroke_color! @bar.color
391
+ pdf.stroke_style! @bar.style
392
+ pdf.line(this_x, line_top_y, this_x, line_bot_y).stroke
393
+ end
394
+
395
+ # Plot the crossbars
396
+ if @upper_crossbar
397
+ if @dot
398
+ cb_width = @dot.style.width
399
+ else
400
+ cb_width = @upper_crossbar.style.width
401
+ end
402
+ pdf.stroke_color! @upper_crossbar.color
403
+ pdf.stroke_style! @upper_crossbar.style
404
+ pdf.line(this_x - cb_width, line_top_y, this_x + cb_width, line_top_y).stroke
405
+ end
406
+ if @lower_crossbar
407
+ if @dot
408
+ cb_width = @dot.style.width
409
+ else
410
+ cb_width = @lower_crossbar.style.width
411
+ end
412
+ pdf.stroke_color! @lower_crossbar.color
413
+ pdf.stroke_style! @lower_crossbar.style
414
+
415
+ pdf.line(this_x - cb_width, line_bot_y, this_x + cb_width, line_bot_y).stroke
416
+ end
417
+ end
418
+
419
+ pdf.restore_state
420
+
421
+ pdf.y = chart_y
422
+
423
+ break if leftover_data.nil?
424
+
425
+ data = leftover_data
426
+ leftover_data = nil
427
+ end
428
+
429
+ pdf.y
430
+ end
431
+ end