Class: ESV::Generator
- Inherits:
-
Object
- Object
- ESV::Generator
- Defined in:
- lib/esv/generator.rb
Instance Method Summary collapse
- #<<(row) ⇒ Object
-
#initialize ⇒ Generator
constructor
A new instance of Generator.
- #render ⇒ Object
Constructor Details
#initialize ⇒ Generator
Returns a new instance of Generator.
2 3 4 |
# File 'lib/esv/generator.rb', line 2 def initialize @data_rows = [] end |
Instance Method Details
#<<(row) ⇒ Object
6 7 8 |
# File 'lib/esv/generator.rb', line 6 def <<(row) @data_rows << row end |
#render ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/esv/generator.rb', line 10 def render book = Spreadsheet::Workbook.new sheet = book.create_worksheet @data_rows.each_with_index do |data_row, index| row = sheet.row(index) row.push(*data_row) end content = "" fake_file = StringIO.new(content) book.write(fake_file) content end |