Class: Thinreports::Preview::Generater
- Inherits:
-
Object
- Object
- Thinreports::Preview::Generater
- Defined in:
- lib/thinreports/preview/generater.rb
Instance Method Summary collapse
- #generate(output, list_loop) ⇒ Object
-
#initialize(file) ⇒ Generater
constructor
A new instance of Generater.
Constructor Details
#initialize(file) ⇒ Generater
Returns a new instance of Generater.
4 5 6 |
# File 'lib/thinreports/preview/generater.rb', line 4 def initialize(file) @file = file end |
Instance Method Details
#generate(output, list_loop) ⇒ Object
8 9 10 11 12 13 14 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 |
# File 'lib/thinreports/preview/generater.rb', line 8 def generate(output, list_loop) name = File.basename(@file, '.*') shapes = ::ThinReports::Layout.new(@file).format.shapes ::ThinReports::Report.generate_file("#{output}/#{name}.pdf", :layout => @file) do start_new_page shapes.each do |k,v| case shapes[k].type when 's-list' tlist = Tlist.new(shapes[k].instance_variable_get("@config")) list(tlist.name).events.on :footer_insert do |e| tlist..each do |key,val| e.section.item(key).value(val.preview_text) end end list_loop.times do |i| list(tlist.name).add_row do |row| tlist.header.each do |key,item| row.item(key).value(item.preview_text) end tlist.items.each do |key, item| row.item(key).value(item.preview_text) end end end when 's-tblock' tblock = Tblock.new(shapes[k].instance_variable_get("@config")) page.values(tblock.name => tblock.preview_text) end end end end |