class Mork::GridPDF

@private GridPDF gets coordinates and measurements from a Grid and provides SheetPDF with the properly computed values

Public Class Methods

new(options=nil) click to toggle source
Calls superclass method Mork::Grid::new
# File lib/mork/grid_pdf.rb, line 8
def initialize(options=nil)
  super options
end

Public Instance Methods

barcode_height() click to toggle source
Calls superclass method Mork::Grid#barcode_height
# File lib/mork/grid_pdf.rb, line 26
def barcode_height
  super.mm
end
barcode_width() click to toggle source
Calls superclass method Mork::Grid#barcode_width
# File lib/mork/grid_pdf.rb, line 22
def barcode_width
  super.mm
end
barcode_xy_for(code) click to toggle source
# File lib/mork/grid_pdf.rb, line 30
def barcode_xy_for(code)
  black = barcode_bits.times.reject { |x| (code>>x)[0]==0 }
  black.map { |x| barcode_xy x+1 }
end
calibration_cells_xy() click to toggle source
# File lib/mork/grid_pdf.rb, line 39
def calibration_cells_xy
  rows.times.map do |q|
    [(reg_frame_width-cell_spacing).mm, item_y(q).mm]
  end
end
choice_spacing() click to toggle source
# File lib/mork/grid_pdf.rb, line 61
def choice_spacing
  cell_spacing.mm
end
cround() click to toggle source
# File lib/mork/grid_pdf.rb, line 69
def cround
  @cround ||= [width_of_cell, height_of_cell].min / 2
end
header_align(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 106
def header_align(k)  @params[:header][k][:align]             end
header_boxed?(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 107
def header_boxed?(k) @params[:header][k][:box] == true       end
header_height(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 104
def header_height(k) @params[:header][k][:height].to_f.mm    end
header_padding(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 116
def header_padding(k)
  [
    1.mm,
    header_height(k) - 1.mm
  ]
end
header_size(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 105
def header_size(k)   @params[:header][k][:size].to_f         end
header_width(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 103
def header_width(k)  @params[:header][k][:width].to_f.mm     end
header_xy(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 109
def header_xy(k)
  [
    @params[:header][k][:left].to_f.mm,
    (reg_frame_height - @params[:header][k][:top].to_f).mm
  ]
end
height_of_cell() click to toggle source
# File lib/mork/grid_pdf.rb, line 57
def height_of_cell
  cell_height.mm
end
height_of_uid() click to toggle source
# File lib/mork/grid_pdf.rb, line 78
def height_of_uid
  uid_cell_height.mm
end
ink_black_xy() click to toggle source
# File lib/mork/grid_pdf.rb, line 35
def ink_black_xy
  barcode_xy 0
end
item_font_size() click to toggle source
# File lib/mork/grid_pdf.rb, line 102
def item_font_size() @params[:items][:font_size].to_f        end
item_xy(q) click to toggle source
# File lib/mork/grid_pdf.rb, line 65
def item_xy(q)
  [item_x(q).mm, item_y(q).mm]
end
margins() click to toggle source
# File lib/mork/grid_pdf.rb, line 99
def margins()        reg_margin.mm                           end
missing_header?(k) click to toggle source
# File lib/mork/grid_pdf.rb, line 94
def missing_header?(k)
  @params[:header][k].nil?
end
page_size() click to toggle source
# File lib/mork/grid_pdf.rb, line 98
def page_size()      [page_width.mm, page_height.mm]         end
qnum_margin() click to toggle source
# File lib/mork/grid_pdf.rb, line 100
def qnum_margin()    @params[:items][:number_margin].to_f.mm end
qnum_width() click to toggle source
# File lib/mork/grid_pdf.rb, line 101
def qnum_width()     @params[:items][:number_width].to_f.mm  end
qnum_xy(q) click to toggle source

Coordinates at which to place item numbers

# File lib/mork/grid_pdf.rb, line 46
def qnum_xy(q)
  [
    item_x(q).mm - qnum_width - qnum_margin,
    item_y(q).mm
  ]
end
reg_marks() click to toggle source
# File lib/mork/grid_pdf.rb, line 12
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
uid_spacing_x() click to toggle source
# File lib/mork/grid_pdf.rb, line 82
def uid_spacing_x
  (uid_width / 11).mm
end
uid_spacing_y() click to toggle source
# File lib/mork/grid_pdf.rb, line 86
def uid_spacing_y
  (uid_height / (uid_digits+1)).mm
end
uround() click to toggle source
# File lib/mork/grid_pdf.rb, line 90
def uround
  @uround ||= [width_of_uid, height_of_uid].min / 2
end
width_of_cell() click to toggle source
# File lib/mork/grid_pdf.rb, line 53
def width_of_cell
  cell_width.mm
end
width_of_uid() click to toggle source

UIDs

# File lib/mork/grid_pdf.rb, line 74
def width_of_uid
  uid_cell_width.mm
end

Private Instance Methods

barcode_area(i) click to toggle source
# File lib/mork/grid_pdf.rb, line 136
def barcode_area(i)
  {
    p: [barcode_bit_x(i).mm, (reg_frame_height - barcode_y).mm],
    w: barcode_width.mm,
    h: barcode_height.mm * 2
  }
end
barcode_xy(i) click to toggle source
# File lib/mork/grid_pdf.rb, line 129
def barcode_xy(i)
  [
    barcode_bit_x(i).mm,
    barcode_height
  ]
end
item_y(q) click to toggle source
# File lib/mork/grid_pdf.rb, line 125
def item_y(q)
  reg_frame_height - cell_y(q)
end