Class: PanicBoardData::Table
- Inherits:
-
Object
- Object
- PanicBoardData::Table
- Defined in:
- lib/panic_board_data/table.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#widths ⇒ Object
Returns the value of attribute widths.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data = []) ⇒ Table
constructor
A new instance of Table.
- #to_csv ⇒ Object
- #to_html ⇒ Object
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
#data ⇒ Object
Returns the value of attribute data.
8 9 10 |
# File 'lib/panic_board_data/table.rb', line 8 def data @data end |
#widths ⇒ Object
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_csv ⇒ Object
18 19 20 |
# File 'lib/panic_board_data/table.rb', line 18 def to_csv self.class.to_csv self.data end |
#to_html ⇒ Object
14 15 16 |
# File 'lib/panic_board_data/table.rb', line 14 def to_html "<table>#{data_to_table_rows}</table>" end |