Class: ActiveModel::ArrayExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/array_exporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, options = {}) ⇒ ArrayExporter

Returns a new instance of ArrayExporter.



7
8
9
10
11
# File 'lib/active_model/array_exporter.rb', line 7

def initialize(collection, options = {})
  @collection = Array(collection)
  @scope      = options.delete(:scope)
  @exporter   = options.delete(:exporter)
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



5
6
7
# File 'lib/active_model/array_exporter.rb', line 5

def collection
  @collection
end

#exporterObject (readonly)

Returns the value of attribute exporter.



5
6
7
# File 'lib/active_model/array_exporter.rb', line 5

def exporter
  @exporter
end

#scopeObject (readonly)

Returns the value of attribute scope.



5
6
7
# File 'lib/active_model/array_exporter.rb', line 5

def scope
  @scope
end

Instance Method Details

#to_csvObject



13
14
15
# File 'lib/active_model/array_exporter.rb', line 13

def to_csv
  generate_file
end

#to_xlsObject



17
18
19
# File 'lib/active_model/array_exporter.rb', line 17

def to_xls
  generate_file(col_sep: "\t")
end