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.
9
10
11
12
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 9
def initialize(generator)
@generator = generator
@table = generator.table
end
|
Instance Attribute Details
#generator ⇒ Object
Returns the value of attribute generator.
7
8
9
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 7
def generator
@generator
end
|
#table ⇒ Object
Returns the value of attribute table.
7
8
9
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 7
def table
@table
end
|
Instance Method Details
#columns_headers(options = {}) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 26
def columns_headers(options={})
, columns = [], table.exportable_columns
for column in columns
datum = column.
<< (options[:encoding] ? datum+".to_s.encode('#{options[:encoding]}')" : datum)
end
return
end
|
#columns_to_array(nature, options = {}) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 35
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.
else
datum = column.exporting_datum_code(record)
end
array << (options[:encoding] ? datum+".to_s.encode('#{options[:encoding]}')" : datum)
end
end
return array
end
|
#file_extension ⇒ Object
14
15
16
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 14
def file_extension
"txt"
end
|
#mime_type ⇒ Object
18
19
20
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 18
def mime_type
Mime::TEXT
end
|
#send_data_code ⇒ Object
22
23
24
|
# File 'lib/active_list/exporters/abstract_exporter.rb', line 22
def send_data_code
raise NotImplementedError, "#{self.class.name}#format_data_code is not implemented."
end
|