Class: Dorsale::Flyboy::Roadmap

Inherits:
Prawn::Document
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper, TextHelper
Defined in:
app/pdfs/dorsale/flyboy/roadmap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TextHelper

#currency, #date, #euros, #hours, #info, #number, #percentage, #text2html

Constructor Details

#initialize(tasks) ⇒ Roadmap

Returns a new instance of Roadmap.



12
13
14
15
# File 'app/pdfs/dorsale/flyboy/roadmap.rb', line 12

def initialize(tasks)
  super(:page_layout => :landscape)
  @tasks = tasks
end

Instance Attribute Details

#tasksObject

Returns the value of attribute tasks.



10
11
12
# File 'app/pdfs/dorsale/flyboy/roadmap.rb', line 10

def tasks
  @tasks
end

Instance Method Details

#buildObject



17
18
19
20
21
22
# File 'app/pdfs/dorsale/flyboy/roadmap.rb', line 17

def build
  font_size 10
  text "Plan d'actions au #{I18n.l(Time.zone.now.to_date)}", :size => 20
  move_down(10)
  display_tasks(@tasks)
end

#display_tasks(tasks) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/pdfs/dorsale/flyboy/roadmap.rb', line 24

def display_tasks(tasks)
  display = [[
    "Taskable",
    "Type",
    "Avancement taskable",
    "Tâche",
    "Avancement tâche",
    "Echéance"
  ]]

  tasks.each do |task|
    display << [
      task.taskable.name,
      task.taskable.class.t,
      percentage(task.taskable.try(:progress)),
      task.name,
      percentage(task.progress),
      I18n.l(task.term)
    ]
  end

  table display
  move_down(10)
end