Class: PanicBoardData::Table

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = []) ⇒ Table

Returns a new instance of Table.



10
11
12
# File 'lib/panic_board_data/table.rb', line 10

def initialize(data = [])
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/panic_board_data/table.rb', line 8

def data
  @data
end

#widthsObject

Returns the value of attribute widths.



8
9
10
# File 'lib/panic_board_data/table.rb', line 8

def widths
  @widths
end

Class Method Details

.to_csv(data) ⇒ Object



22
23
24
25
26
# File 'lib/panic_board_data/table.rb', line 22

def self.to_csv data
  ::CSV.generate do |csv|
    data.each { |row| csv << row }
  end.strip
end

Instance Method Details

#to_csvObject



18
19
20
# File 'lib/panic_board_data/table.rb', line 18

def to_csv
  self.class.to_csv self.data
end

#to_htmlObject



14
15
16
# File 'lib/panic_board_data/table.rb', line 14

def to_html
  "<table>#{data_to_table_rows}</table>"
end