Class: Labimotion::ExportDataset
- Inherits:
-
Object
- Object
- Labimotion::ExportDataset
- Defined in:
- lib/labimotion/libs/export_dataset.rb
Overview
ExportDataset
Constant Summary collapse
- DEFAULT_ROW_WIDTH =
100- DEFAULT_ROW_HEIGHT =
20
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(id) ⇒ ExportDataset
constructor
A new instance of ExportDataset.
- #read ⇒ Object
- #res_name ⇒ Object
Constructor Details
#initialize(id) ⇒ ExportDataset
Returns a new instance of ExportDataset.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/labimotion/libs/export_dataset.rb', line 11 def initialize(id) @xfile = Axlsx::Package.new @xfile.workbook.styles.fonts.first.name = 'Calibri' @file_extension = 'xlsx' @id = id @dataset = Labimotion::Dataset.find_by(element_id: @id, element_type: 'Container') return if @dataset.nil? @klass = @dataset.dataset_klass @ols_term_id = @klass.ols_term_id @label = @klass.label @analysis = @dataset&.element&.parent @element = @analysis&.root&.containable if @analysis.present? @element_type = @element.class.name if @element.present? @spectra_values = [] end |
Instance Method Details
#export ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/labimotion/libs/export_dataset.rb', line 41 def export return if @dataset.nil? || @analysis.nil? || @element.nil? description dataset_info spectra_info chemwiki_info rescue StandardError => e Labimotion.log_exception(e) end |
#read ⇒ Object
29 30 31 |
# File 'lib/labimotion/libs/export_dataset.rb', line 29 def read @xfile.to_stream.read end |
#res_name ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/labimotion/libs/export_dataset.rb', line 33 def res_name element_name = Container.find(@id)&.root_element&.short_label ols = ols_name "#{element_name}_#{ols.gsub(' ', '_')}.xlsx" rescue StandardError => e Labimotion.log_exception(e) end |