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

.base_tens_shapes_paper(npages, rule_value = 1, rule_unit = 'cm', filename = 'output.pdf') ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/teaching_printables/factory.rb', line 46

def Factory.base_tens_shapes_paper(npages,rule_value=1,rule_unit='cm',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 Shapeable
    include QuadRulable
  end
  npages.times do |i|
    doc.create_quad_rule(rule_unit: rule, start_new_page: true)
    doc.create_tens_and_ones_shapes(rule_unit: rule, start_new_page: false)
    doc.text_box "Name:", :at => [2.cm, doc.bounds.top - 1.cm]
    doc.line_width = 2
    doc.stroke_color = "000000"
    doc.stroke_line  [3.5.cm,doc.bounds.top - 1.5.cm], [10.cm,doc.bounds.top - 1.5.cm] 
    doc.text_box "Date:", :at => [12.cm, doc.bounds.top - 1.cm]
    doc.stroke_line  [13.cm,doc.bounds.top - 1.5.cm], [20.cm,doc.bounds.top - 1.5.cm]
  end
  doc.save_as(filename)

end

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



73
74
75
76
77
78
79
80
# File 'lib/teaching_printables/factory.rb', line 73

def Factory.centimeter_number_lines(output_file_name = "output.pdf")
  doc = TeachingPrintables::TPDocument.new
  class << doc
    include Gridable
  end
  update_grid_options(grid_rows: 5, grid_columns: 1)
  
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



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/teaching_printables/factory.rb', line 82

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