Class: PDFPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resume) ⇒ PDFPrinter

Returns a new instance of PDFPrinter.



7
8
9
# File 'lib/pdf_printer.rb', line 7

def initialize(resume)
  self.resume = resume
end

Instance Attribute Details

#resumeObject

Returns the value of attribute resume.



5
6
7
# File 'lib/pdf_printer.rb', line 5

def resume
  @resume
end

Instance Method Details

#filenameObject



11
12
13
# File 'lib/pdf_printer.rb', line 11

def filename
  "#{self.resume.name}.pdf"
end


15
16
17
18
19
20
21
22
23
24
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
# File 'lib/pdf_printer.rb', line 15

def print
  resume = self.resume
  Prawn::Document.generate filename do
    font "Helvetica"
    header margin_box.top_left do
      text resume.my_name, :align => :center, :size => 32
      text resume.print_contact, :align => :center
      stroke_horizontal_rule
    end
    move_down(50)
    if(resume.has_schools?)
      text "Education", :align => :right, :style => :bold_italic
      text resume.print_schools, :align => :left
      stroke_horizontal_rule
    end
    if(resume.has_jobs?)
      text "Employment", :align => :right, :style => :bold_italic
      text resume.print_jobs, :align => :left
      stroke_horizontal_rule
    end
    
    if(resume.has_applications?)
      text "Sites", :align => :right, :style => :bold_italic
      text resume.print_array(resume.applications), :align => :center
      stroke_horizontal_rule
    end
    
    if(resume.has_technologies?)
      text "Technologies", :align => :right, :style => :bold_italic
      text resume.print_array(resume.technologies), :align => :center
      stroke_horizontal_rule
    end
    
    if(resume.has_practices?)
      text "Practices", :align => :right, :style => :bold_italic
      text resume.print_array(resume.practices), :align => :center
      stroke_horizontal_rule
    end
    
    if(resume.has_story?)
      text resume.story_text
    end
    
    footer margin_box.bottom_left do
      font "Courier"
      fill_color "999999"
      
      text "gem install resume; resume #{$*}", :align => :center, :size => 8
    end
  end    
end