Class: Datev::Export
- Inherits:
-
Object
- Object
- Datev::Export
- Defined in:
- lib/datev/export.rb
Constant Summary collapse
- CSV_OPTIONS =
{ :col_sep => ';', :encoding => 'windows-1252' }
Instance Method Summary collapse
- #<<(attributes) ⇒ Object
-
#initialize(header_attributes) ⇒ Export
constructor
A new instance of Export.
- #to_file(filename) ⇒ Object
- #to_s ⇒ Object
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 = Header.new header_attributes @rows = [] end |
Instance Method Details
#<<(attributes) ⇒ Object
14 15 16 |
# File 'lib/datev/export.rb', line 14 def <<(attributes) @rows << Datev::Booking.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_s ⇒ Object
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 |