Sha256: 10e1a7b4178b462f3e4eb16902237b2a117d829855f1d112ea3bde54a59c7930
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
module ActiveList module Exporters class AbstractExporter attr_reader :table, :generator def initialize(generator) @generator = generator @table = generator.table end def file_extension "txt" end def mime_type Mime::TEXT end def send_data_code raise NotImplementedError, "#{self.class.name}#format_data_code is not implemented." end def columns_headers(options={}) headers, columns = [], table.exportable_columns for column in columns datum = column.header_code headers << (options[:encoding] ? datum+".to_s.encode('#{options[:encoding]}', invalid: :replace, undef: :replace)" : datum) end return headers end def columns_to_array(nature, options={}) columns = table.exportable_columns array = [] record = options[:record] || 'record_of_the_death' for column in columns if column.is_a?(ActiveList::Definition::AbstractColumn) if nature == :header datum = column.header_code else datum = column.exporting_datum_code(record) end array << (options[:encoding] ? datum+".to_s.encode('#{options[:encoding]}', invalid: :replace, undef: :replace)" : datum) end end return array end end end end
Version data entries
3 entries across 3 versions & 1 rubygems