Method: Qif::Transaction#to_s
- Defined in:
- lib/qif/transaction.rb
#to_s(format = 'dd/mm/yyyy') ⇒ Object
Returns a representation of the transaction as it would appear in a qif file.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/qif/transaction.rb', line 40 def to_s(format = 'dd/mm/yyyy') SUPPORTED_FIELDS.collect do |k,v| next unless current = instance_variable_get("@#{k}") field = v.keys.first case current.class.to_s when "Time", "Date", "DateTime" "#{field}#{DateFormat.new(format).format(current)}" when "Float" "#{field}#{'%.2f'%current}" when "String" current.split("\n").collect {|x| "#{field}#{x}" } else "#{field}#{current}" end end.concat(@splits.collect{|s| s.to_s}).flatten.compact.join("\n") end |