Class: ActiveReport::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/active_report/array.rb

Instance Method Summary collapse

Methods inherited from Base

#csv_force_encoding?, #csv_options, evaluate, export, import, #import_adapter, #import_options, #initialize

Constructor Details

This class inherits a constructor from ActiveReport::Base

Instance Method Details

#exportObject



5
6
7
8
9
10
# File 'lib/active_report/array.rb', line 5

def export
  @data = munge_first(@data)
  @data = @data.unshift(@opts[:headers]) unless @opts[:headers].nil?

  @opts[:stream] ? export_stream : export_csv
end

#importObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_report/array.rb', line 12

def import
  array = merge(@opts[:headers])

  CSV.foreach(@data, @opts[:options]) do |row|
    row = encode_to_utf8(row) if csv_force_encoding?
    array.push(row)
  end

  array = array.flatten if array.size < 2
  metatransform(array)
end