Class: Wizport::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/wizport/engine/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Report

Returns a new instance of Report.



10
11
12
13
14
15
16
17
# File 'lib/wizport/engine/report.rb', line 10

def initialize(options = {})
  @title = options.delete(:title) || ""
  @subtitle = options.delete(:subtitle) || ""
  @columns = options.delete(:columns) || []
  @sections = options.delete(:sections) || []
  @source = Wizport::MongoidSource.new(options.delete(:source))

end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



8
9
10
# File 'lib/wizport/engine/report.rb', line 8

def columns
  @columns
end

#sectionsObject

Returns the value of attribute sections.



8
9
10
# File 'lib/wizport/engine/report.rb', line 8

def sections
  @sections
end

#sourceObject

Returns the value of attribute source.



8
9
10
# File 'lib/wizport/engine/report.rb', line 8

def source
  @source
end

#subtitleObject

Returns the value of attribute subtitle.



8
9
10
# File 'lib/wizport/engine/report.rb', line 8

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/wizport/engine/report.rb', line 8

def title
  @title
end

Instance Method Details

#add_column(column) ⇒ Object



28
29
30
# File 'lib/wizport/engine/report.rb', line 28

def add_column(column)
  @columns << column
end

#build(format = :pdf) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wizport/engine/report.rb', line 32

def build(format = :pdf)
  builder = Wizport::Builder::Pdf.new(self)
  builder.header
  if sections.size > 0
  sections.each do |section|
    builder.section(section)
  end
  else
    builder.grid
  end
  builder.footer
  builder
end

#column(options) ⇒ Object



19
20
21
# File 'lib/wizport/engine/report.rb', line 19

def column(options)
  @columns << Wizport::Column.new(options)
end

#save(file) ⇒ Object



46
47
48
# File 'lib/wizport/engine/report.rb', line 46

def save(file)
  build(:pdf).save(file)
end

#section(options) ⇒ Object



23
24
25
26
# File 'lib/wizport/engine/report.rb', line 23

def section(options)
  @sections << Wizport::Section.new(options)

end