File: multipage_batch.rb

package info (click to toggle)
libtioga-ruby 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,956 kB
  • ctags: 3,257
  • sloc: ansic: 31,801; ruby: 16,346; sh: 172; makefile: 114
file content (45 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# multipage.rb

require 'Tioga/FigureMaker'
include Tioga

class MyFigures

   include Tioga
   include FigureConstants

   def t
      @figure_maker
   end

   def initialize
      @figure_maker = FigureMaker.default
      t.def_eval_function { |str| eval(str) }
      t.def_figure("one_page") { one_page }
      t.save_dir = 'figures_out'
      @page_number = 0
   end

   def one_page # show the value of @page_number
      t.fill_color = Red
      t.fill_frame
      t.show_label('text'=>sprintf('%i',@page_number),
         'x' => 0.5, 'y' => 0.5, 'scale' => 2)
   end

   def do_one(n)
      @page_number = n
      t.make_pdf('one_page')
      syscmd = 'mv ' + t.save_dir + '/one_page.pdf page_' + n.to_s + '.pdf '
      puts syscmd
      system(syscmd)
   end

   def do_lots(first,cnt)
      cnt.times { |i| do_one(first+i) }
   end

end

MyFigures.new
FigureMaker.default.eval_function("do_lots(1,5)")