Class: SimpleCV::Layout

Inherits:
Prawn::Document
  • Object
show all
Defined in:
lib/simple_cv/layout.rb

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Layout

Returns a new instance of Layout.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simple_cv/layout.rb', line 7

def initialize config:
  @config = config

  super({
    page_size: "A4",
    info: {
      Title: @config.title,
      Author: @config.author,
      Creator: "AwesomeCV",
      Producer: "AwesomeCV",
      CreationDate: Time.now
    }
  })

  font_families.update "Default" => default_font_files
  font "Default"
  stroke_color "000000"
  main
end

Instance Method Details

#contactObject



60
61
62
63
64
# File 'lib/simple_cv/layout.rb', line 60

def contact
  h2 "contact"
  contact_table
  move_down 25
end

#educationObject



84
85
86
87
88
89
90
91
92
# File 'lib/simple_cv/layout.rb', line 84

def education
  h2 "education"
  @config.education&.each do |elem|
    h3 elem.subject
    h4 elem.institution
    h4 elem.date
    move_down 14
  end
end

#experienceObject



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/simple_cv/layout.rb', line 72

def experience
  h2 "experience"
  @config.experience&.each do |elem|
    h3 elem.job
    h4 "#{elem.company} - #{elem.location}"
    h4 elem.date
    move_down 5
    paragaph elem.description
    move_down 14
  end
end

#jobObject



47
48
49
50
51
52
# File 'lib/simple_cv/layout.rb', line 47

def job
  h1 @config.profile&.name
  text @config.profile&.job, style: :normal, size: 11
  stroke
  move_down 25
end

#mainObject

Main

This builds main layout. Document is diveded in two columns. First column provides personal details and skills, second column show historic experience and education.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/simple_cv/layout.rb', line 33

def main
  bounding_box([0, 770], width: 170) do
    job
    profile
    contact
    skills
  end

  bounding_box([200, 770], width: 320) do
    experience
    education
  end
end

#profileObject



54
55
56
57
58
# File 'lib/simple_cv/layout.rb', line 54

def profile
  h2 "profile"
  text @config.profile&.description, style: :normal, size: 10
  move_down 25
end

#skillsObject



66
67
68
69
70
# File 'lib/simple_cv/layout.rb', line 66

def skills
  h2 "skills"
  skill_table
  move_down 25
end