Class: Datev::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/datev/export.rb

Direct Known Subclasses

AccountExport, BookingExport

Constant Summary collapse

CSV_OPTIONS =
{ :col_sep => ';', :encoding => 'windows-1252' }

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header_attributes) ⇒ Export

Returns a new instance of Export.


9
10
11
12
# File 'lib/datev/export.rb', line 9

def initialize(header_attributes)
  @header = self.class.header_class.new(header_attributes)
  @rows = []
end

Class Attribute Details

.header_classObject

Returns the value of attribute header_class


6
7
8
# File 'lib/datev/export.rb', line 6

def header_class
  @header_class
end

.row_classObject

Returns the value of attribute row_class


6
7
8
# File 'lib/datev/export.rb', line 6

def row_class
  @row_class
end

Instance Method Details

#<<(attributes) ⇒ Object


14
15
16
# File 'lib/datev/export.rb', line 14

def <<(attributes)
  @rows << self.class.row_class.new(attributes)
end

#to_file(filename) ⇒ Object


24
25
26
27
28
# File 'lib/datev/export.rb', line 24

def to_file(filename)
  CSV.open(filename, 'wb', CSV_OPTIONS) do |csv|
    write(csv)
  end
end

#to_sObject


18
19
20
21
22
# File 'lib/datev/export.rb', line 18

def to_s
  CSV.generate(CSV_OPTIONS) do |csv|
    write(csv)
  end
end