class Ruport::Formatter::PrawnPDF

Attributes

pdf[RW]

Public Instance Methods

build_group_body() click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 55
def build_group_body
  render_table data, options.to_hash.merge(:formatter => pdf)
end
build_grouping_body() click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 59
def build_grouping_body
  data.each do |name,group|

    # Group heading
    move_down(20)
    text name, :style => :bold, :size => 15

    # Table
    move_down(10)
    draw_table group
  end
end
build_table_body() click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 51
def build_table_body
  draw_table(data)
end
draw_table(table, format_opts={}) click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 23
def draw_table(table, format_opts={})
  m = "PDF Formatter requires column_names to be defined"
  raise FormatterError, m if table.column_names.empty?

  table.rename_columns { |c| c.to_s }

  table_array = [table.column_names]
  table_array += table_to_array(table)
  table_array.map { |array| array.map! { |elem| elem.class != String ? elem.to_s : elem }}

  if options[:table_format]
    opt = options[:table_format] 
  else
    opt = {}
  end

  pdf.table(table_array,opt)

end
finalize() click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 47
def finalize
  output << pdf.render
end
method_missing(id,*args, &block) click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 9
def method_missing(id,*args, &block)
  pdf.send(id,*args, &block)
end
table_to_array(tbl) click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 43
def table_to_array(tbl)
  tbl.map { |row| row.to_a}
end

Public Class Methods

new() click to toggle source
# File lib/ruport/formatter/prawn_pdf.rb, line 13
def initialize
  require 'prawn'
  require 'prawn/layout'
end