Class: Rgviz::TableBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rgviz/table_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(columns = []) ⇒ TableBuilder

Returns a new instance of TableBuilder.



3
4
5
6
7
8
# File 'lib/rgviz/table_builder.rb', line 3

def initialize(columns = [])
  @table = Rgviz::Table.new
  columns.each do |column|
    @table.cols << Rgviz::Column.new(column)
  end
end

Instance Method Details

#add_row(*values) ⇒ Object



14
15
16
17
18
# File 'lib/rgviz/table_builder.rb', line 14

def add_row(*values)
  @table.rows << Rgviz::Row.new(
    :c => values.map { |value| Rgviz::Cell.new(:v => value) }
  )
end

#tableObject



10
11
12
# File 'lib/rgviz/table_builder.rb', line 10

def table
  @table
end