Class: ReportEngine::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/report_engine/table.rb

Direct Known Subclasses

Html::Table, Pdf::Table, SubTable

Instance Method Summary collapse

Constructor Details

#initialize(canvas, options) ⇒ Table

Returns a new instance of Table.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/report_engine/table.rb', line 3

def initialize(canvas, options)
  @canvas = canvas
  @data      = options[:data].clone
  @axis_title= options[:axis_title] || "Axes"
  @x_label   = options[:x_label]
  @y_label   = options[:y_label]
  @x_headers = options[:x_headers]
  @y_headers = options[:y_headers]
  @border_color = options[:border_color] || '000000'
  @row_colors = options[:row_colors] || []
  @column_widths = options[:column_widths] || {}
  @legends = options[:legends]
end

Instance Method Details

#add_headersObject



25
26
27
28
# File 'lib/report_engine/table.rb', line 25

def add_headers
  add_y_headers
  @data.insert 0, @x_headers
end

#add_y_headersObject



17
18
19
20
21
22
23
# File 'lib/report_engine/table.rb', line 17

def add_y_headers
  if !@y_headers.nil? && !@y_headers.empty?
    @data.each_with_index do |line, i|
      line.insert(0, @y_headers[i] )
    end
  end
end

#dataObject



30
31
32
# File 'lib/report_engine/table.rb', line 30

def data
  return @data
end