Class: ExcelAbstraction::SpreadSheet
- Inherits:
-
Tempfile
- Object
- Tempfile
- ExcelAbstraction::SpreadSheet
- Defined in:
- lib/excel_templating/excel_abstraction/spread_sheet.rb
Instance Attribute Summary collapse
-
#workbook ⇒ Object
readonly
Returns the value of attribute workbook.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(format: :xls, skip_default_sheet: false) ⇒ SpreadSheet
constructor
A new instance of SpreadSheet.
- #to_s ⇒ Object
Constructor Details
#initialize(format: :xls, skip_default_sheet: false) ⇒ SpreadSheet
Returns a new instance of SpreadSheet.
7 8 9 10 11 12 |
# File 'lib/excel_templating/excel_abstraction/spread_sheet.rb', line 7 def initialize(format: :xls, skip_default_sheet: false) extension = format == :xls ? ".xls" : ".xlsx" tmp_file = Tempfile.new(["temp_spreadsheet_#{::Time.now.to_i}", extension]) super(tmp_file) @workbook = ExcelAbstraction::WorkBook.new(tmp_file.path, format: format, skip_default_sheet: skip_default_sheet) end |
Instance Attribute Details
#workbook ⇒ Object (readonly)
Returns the value of attribute workbook.
5 6 7 |
# File 'lib/excel_templating/excel_abstraction/spread_sheet.rb', line 5 def workbook @workbook end |
Instance Method Details
#close ⇒ Object
14 15 16 17 18 |
# File 'lib/excel_templating/excel_abstraction/spread_sheet.rb', line 14 def close workbook.close yield if block_given? super end |
#to_s ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/excel_templating/excel_abstraction/spread_sheet.rb', line 20 def to_s data = nil close do data = read end data end |