Module: TeachingPrintables::Factory

Defined in:
lib/teaching_printables/factory.rb

Overview

Rubber stamps common worksheets

Class Method Summary collapse

Class Method Details

.avery5371_with_array_content(content_array, output_file_name = "output.pdf") ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/teaching_printables/factory.rb', line 6

def Factory.avery5371_with_array_content(content_array,output_file_name="output.pdf")
  doc = TeachingPrintables::TPDocument.new
  class << doc
    include TeachingPrintables::Templatable
  end
  doc.create_page_with_template(:avery5371)
  doc.add_grid_content(content_array)
  doc.save_as(output_file_name)
  puts "Sheet saved as #{output_file_name}."
end

.centimeter_paperObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/teaching_printables/factory.rb', line 17

def Factory.centimeter_paper
  doc = TeachingPrintables::TPDocument.new
  class << doc
    include QuadRulable
  end
  2.times do |i|
    doc.create_quad_rule(start_new_page: true)
  end
  doc.save_as(output_file_name)
end

.hundreds_grid(output_file_name = "output.pdf") ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/teaching_printables/factory.rb', line 47

def Factory.hundreds_grid(output_file_name="output.pdf")
  qr=TeachingPrintables::TPDocument.new
  class << qr
    include QuadRulable
  end
  2.times do |i| 
    qr.create_quad_rule(start_new_page: true)
    qr.line_width = 4
    qr.stroke_rectangle [1.cm,11.cm], 10.cm, 10.cm
    qr.stroke_line [6.cm,11.cm], [6.cm,21.cm]
    qr.stroke_rectangle [1.cm,22.cm], 10.cm, 10.cm
    qr.stroke_line [6.cm,21.cm], [6.cm,31.cm]
  end
  qr.save_as(output_file_name)
end

.quad_ruled_paper(npages, rule_value, rule_unit = '', filename = 'output.pdf') ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/teaching_printables/factory.rb', line 28

def Factory.quad_ruled_paper(npages,rule_value,rule_unit='',filename='output.pdf')
  npages = npages.to_i
  rule = rule_unit.empty? ? rule_value.to_f : rule_value.to_f.send(rule_unit)
  
  if !filename || filename.empty?
    filename = 'output.pdf'
  end
  
  doc = TeachingPrintables::TPDocument.new
  class << doc
    include QuadRulable
  end
  npages.times do |i|
    doc.create_quad_rule(rule_unit: rule, start_new_page: true)
  end
  doc.save_as(filename)
end