Class: ActiveList::Exporters::AbstractExporter
- Inherits:
-
Object
- Object
- ActiveList::Exporters::AbstractExporter
show all
- Defined in:
- lib/active_list/exporters/abstract_exporter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of AbstractExporter.
6
7
8
9
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 6
def initialize(generator)
@generator = generator
@table = generator.table
end
|
Instance Attribute Details
#generator ⇒ Object
Returns the value of attribute generator.
4
5
6
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 4
def generator
@generator
end
|
#table ⇒ Object
Returns the value of attribute table.
4
5
6
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 4
def table
@table
end
|
Instance Method Details
#columns_headers(options = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 23
def columns_headers(options = {})
= []
columns = table.exportable_columns
for column in columns
datum = column.
<< (options[:encoding] ? datum + ".to_s.encode('#{options[:encoding]}', invalid: :replace, undef: :replace)" : datum)
end
end
|
#columns_to_array(nature, options = {}) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 33
def columns_to_array(nature, options = {})
columns = table.exportable_columns
array = []
record = options[:record] || 'record_of_the_death'
for column in columns
next unless column.is_a?(ActiveList::Definition::AbstractColumn)
datum = if nature == :header
column.
else
column.exporting_datum_code(record)
end
array << (options[:encoding] ? datum + ".to_s.encode('#{options[:encoding]}', invalid: :replace, undef: :replace)" : datum)
end
array
end
|
#file_extension ⇒ Object
11
12
13
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 11
def file_extension
'txt'
end
|
#mime_type ⇒ Object
15
16
17
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 15
def mime_type
Mime::TEXT
end
|
#send_data_code ⇒ Object
19
20
21
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 19
def send_data_code
raise NotImplementedError, "#{self.class.name}#format_data_code is not implemented."
end
|