Class: Wizport::Builder::Pdf

Inherits:
Object
  • Object
show all
Defined in:
lib/wizport/builder/pdf.rb

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ Pdf

Returns a new instance of Pdf.



9
10
11
12
# File 'lib/wizport/builder/pdf.rb', line 9

def initialize(report)
  @rpt = report
  @pdf = Wizport::Document::Pdf.new
end

Instance Method Details



55
56
57
# File 'lib/wizport/builder/pdf.rb', line 55

def footer

end

#gridObject



18
19
20
21
22
23
24
25
# File 'lib/wizport/builder/pdf.rb', line 18

def grid
  tbl = []
  tbl << @rpt.columns.map {|c| c.title }
  @rpt.source.all.each do |obj|
    tbl << @rpt.columns.map {|c| obj.send(c.name)}
  end
  @pdf.table tbl
end

#headerObject



14
15
16
# File 'lib/wizport/builder/pdf.rb', line 14

def header
  @pdf.text @rpt.title
end

#save(file) ⇒ Object



59
60
61
# File 'lib/wizport/builder/pdf.rb', line 59

def save(file)
  @pdf.save(file)
end

#section(section) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/wizport/builder/pdf.rb', line 27

def section(section)
  @tbl = []
  @rpt.source.groups(section).each do |group|
    section_header(section,group)
    section_body(section,group)
    (section,group)
  end
  @pdf.table @tbl
end

#section_body(section, group) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/wizport/builder/pdf.rb', line 41

def section_body(section,group)
  rows = []
  rows << @rpt.columns.map {|c| c.title }
  objs = @rpt.source.filter({section.group => group})
  objs.each do |obj|
    rows << @rpt.columns.map {|c| obj.send(c.name)}
  end
  @tbl << [@pdf.make_table(rows)]
end


51
52
53
# File 'lib/wizport/builder/pdf.rb', line 51

def (section,group)

end

#section_header(section, group) ⇒ Object



37
38
39
# File 'lib/wizport/builder/pdf.rb', line 37

def section_header(section,group)
  @tbl << ["#{section.title}:#{group}"]
end