Class: Mork::GridPDF
- Inherits:
-
Grid
- Object
- Grid
- Mork::GridPDF
show all
- Defined in:
- lib/mork/grid_pdf.rb
Overview
GridPDF gets coordinates and measurements from a Grid and provides SheetPDF with the properly computed values
Instance Method Summary
collapse
Methods inherited from Grid
#barcode_bits, #max_choices_per_question, #max_questions, #options, #rm_blur, #rm_dilate, #show
Constructor Details
#initialize(options = nil) ⇒ GridPDF
Returns a new instance of GridPDF.
7
8
9
|
# File 'lib/mork/grid_pdf.rb', line 7
def initialize(options=nil)
super options
end
|
Instance Method Details
#barcode_height ⇒ Object
25
26
27
|
# File 'lib/mork/grid_pdf.rb', line 25
def barcode_height
super.mm
end
|
#barcode_width ⇒ Object
21
22
23
|
# File 'lib/mork/grid_pdf.rb', line 21
def barcode_width
super.mm
end
|
#barcode_xy_for(code) ⇒ Object
29
30
31
32
|
# File 'lib/mork/grid_pdf.rb', line 29
def barcode_xy_for(code)
black = barcode_bits.times.reject { |x| (code>>x)[0]==0 }
black.collect { |x| barcode_xy x+1 }
end
|
#calibration_cells_xy ⇒ Object
38
39
40
41
42
|
# File 'lib/mork/grid_pdf.rb', line 38
def calibration_cells_xy
rows.times.collect do |q|
[(reg_frame_width-cell_spacing).mm, item_y(q).mm]
end
end
|
#choice_spacing ⇒ Object
60
61
62
|
# File 'lib/mork/grid_pdf.rb', line 60
def choice_spacing
cell_spacing.mm
end
|
#cround ⇒ Object
68
69
70
|
# File 'lib/mork/grid_pdf.rb', line 68
def cround
@cround ||= [width_of_cell, height_of_cell].min / 2
end
|
80
|
# File 'lib/mork/grid_pdf.rb', line 80
def (k) @params[:header][k][:align] end
|
81
|
# File 'lib/mork/grid_pdf.rb', line 81
def (k) @params[:header][k][:box] == true end
|
78
|
# File 'lib/mork/grid_pdf.rb', line 78
def (k) @params[:header][k][:height].to_f.mm end
|
90
91
92
93
94
95
|
# File 'lib/mork/grid_pdf.rb', line 90
def (k)
[
1.mm,
(k) - 1.mm
]
end
|
79
|
# File 'lib/mork/grid_pdf.rb', line 79
def (k) @params[:header][k][:size].to_f end
|
77
|
# File 'lib/mork/grid_pdf.rb', line 77
def (k) @params[:header][k][:width].to_f.mm end
|
83
84
85
86
87
88
|
# File 'lib/mork/grid_pdf.rb', line 83
def (k)
[
@params[:header][k][:left].to_f.mm,
(reg_frame_height - @params[:header][k][:top].to_f).mm
]
end
|
#height_of_cell ⇒ Object
56
57
58
|
# File 'lib/mork/grid_pdf.rb', line 56
def height_of_cell
cell_height.mm
end
|
#ink_black_xy ⇒ Object
34
35
36
|
# File 'lib/mork/grid_pdf.rb', line 34
def ink_black_xy
barcode_xy 0
end
|
#item_font_size ⇒ Object
76
|
# File 'lib/mork/grid_pdf.rb', line 76
def item_font_size() @params[:items][:font_size].to_f end
|
#item_xy(q) ⇒ Object
64
65
66
|
# File 'lib/mork/grid_pdf.rb', line 64
def item_xy(q)
[item_x(q).mm, item_y(q).mm]
end
|
#margins ⇒ Object
73
|
# File 'lib/mork/grid_pdf.rb', line 73
def margins() reg_margin.mm end
|
#page_size ⇒ Object
72
|
# File 'lib/mork/grid_pdf.rb', line 72
def page_size() [page_width.mm, page_height.mm] end
|
#qnum_margin ⇒ Object
74
|
# File 'lib/mork/grid_pdf.rb', line 74
def qnum_margin() @params[:items][:number_margin].to_f.mm end
|
#qnum_width ⇒ Object
75
|
# File 'lib/mork/grid_pdf.rb', line 75
def qnum_width() @params[:items][:number_width].to_f.mm end
|
#qnum_xy(q) ⇒ Object
Coordinates at which to place item numbers
45
46
47
48
49
50
|
# File 'lib/mork/grid_pdf.rb', line 45
def qnum_xy(q)
[
item_x(q).mm - qnum_width - qnum_margin,
item_y(q).mm
]
end
|
#reg_marks ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/mork/grid_pdf.rb', line 11
def reg_marks
r = reg_radius.mm
[
{ p: [0, 0 ], r: r },
{ p: [0, reg_frame_height.mm], r: r },
{ p: [reg_frame_width.mm, reg_frame_height.mm], r: r },
{ p: [reg_frame_width.mm, 0 ], r: r }
]
end
|
#width_of_cell ⇒ Object
52
53
54
|
# File 'lib/mork/grid_pdf.rb', line 52
def width_of_cell
cell_width.mm
end
|