lib/datev/export.rb in datev-0.2.3 vs lib/datev/export.rb in datev-0.3.0

- old
+ new

@@ -1,20 +1,23 @@ require 'csv' require 'datev/header' -require 'datev/booking' module Datev class Export CSV_OPTIONS = { :col_sep => ';', :encoding => 'windows-1252' } + class << self + attr_accessor :header_class, :row_class + end + def initialize(header_attributes) - @header = Header.new header_attributes + @header = self.class.header_class.new(header_attributes) @rows = [] end def <<(attributes) - @rows << Datev::Booking.new(attributes) + @rows << self.class.row_class.new(attributes) end def to_s CSV.generate(CSV_OPTIONS) do |csv| write(csv) @@ -29,10 +32,10 @@ private def write(csv) csv << @header.output - csv << Booking.fields.map(&:name) + csv << self.class.row_class.fields.map(&:name) @rows.each do |row| csv << row.output(@header) end end