Class: ActiveSet::Exporting::CSVStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_set/exporting/csv_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(set, column_instructions) ⇒ CSVStrategy

Returns a new instance of CSVStrategy.



10
11
12
13
# File 'lib/active_set/exporting/csv_strategy.rb', line 10

def initialize(set, column_instructions)
  @set = set
  @column_instructions = column_instructions
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
# File 'lib/active_set/exporting/csv_strategy.rb', line 15

def execute
  ::CSV.generate do |output|
    output << column_keys_for(item: @set.first)
    @set.each do |item|
      output << column_values_for(item: item)
    end
  end
end