Class: OutwoodLabels::Template::EmailPassword

Inherits:
Base
  • Object
show all
Defined in:
lib/outwood_labels/template/email_password.rb

Direct Known Subclasses

EmailPasswordInitial

Constant Summary collapse

PADDING =
6

Class Method Summary collapse

Methods inherited from Base

accept_columns, page_layout, template_name, valid_for?

Methods included from Callable

included

Class Method Details

.evaluate(pdf, data) ⇒ Object

Parameters:

  • data (#[])

    data object

  • pdf (Prawn::Document)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/outwood_labels/template/email_password.rb', line 25

def self.evaluate(pdf, data)
  b = pdf.bounds
  full_width = b.width - (PADDING * 2)
  col1 = (full_width / 3).floor - 1
  col2 = (col1 * 2) - 1

  pdf.font 'Helvetica'

  pdf.move_down (PADDING * 2).round
  pdf.indent(PADDING) do
    pdf.text_box "#{data['firstname']} #{data['lastname']}",
      at: [b.left, pdf.cursor],
      width: full_width, height: 12,
      overflow: :truncate
  end
  pdf.move_down 12
  pdf.stroke_horizontal_rule
  pdf.move_down 6
  pdf.indent(PADDING) do
    pdf.font "Helvetica", size: 7 do
      pdf.text_box "Admin no.",
        at: [b.left, pdf.cursor],
        width: col1, height: 8
      pdf.text_box "Group",
        at: [b.right - col2, pdf.cursor],
        width: col2, height: 8
    end
    pdf.move_down 9
    pdf.text_box (data["admin"] || ""),
      at: [b.left, pdf.cursor],
      width: col1, height: 10,
      overflow: :shrink_to_fit
    pdf.text_box (data["vmg"] || ""),
      at: [b.right - col2, pdf.cursor],
      width: col2, height: 10,
      overflow: :shrink_to_fit
    pdf.move_down 16
    pdf.font_size 7 do
      pdf.text_box "Email",
        at: [b.left, pdf.cursor],
        width: full_width, height: 8
    end
    pdf.move_down 9
    pdf.text_box (data["email"] || ""),
      at: [b.left, pdf.cursor],
      width: full_width, height: 12,
      overflow: :shrink_to_fit
    pdf.move_down 16
    pdf.font_size 7 do
      pdf.text_box password_label,
        at: [b.left, pdf.cursor],
        width: full_width, height: 8
    end
    pdf.move_down 9
    pdf.font "Courier" do
      pdf.text_box (data["password"] || ""),
        at: [b.left, pdf.cursor],
        width: full_width, height: 12,
        overflow: :shrink_to_fit
    end
  end
end

.password_labelObject



19
20
21
# File 'lib/outwood_labels/template/email_password.rb', line 19

def self.password_label
  "Password"
end