class AspireBudget::Models::Transaction
Attributes
account[R]
category[R]
date[R]
inflow[R]
memo[R]
outflow[R]
status[R]
Public Class Methods
from_row(header, row)
click to toggle source
# File lib/aspire_budget/models/transaction.rb, line 10 def self.from_row(header, row) params = header.zip(row).to_h params.tap do |h| h[:date] = Utils.parse_date(h[:date]) h[:status] = Utils.parse_status(h[:status]) end new(**params) end
new(date:, outflow:, inflow:, category:, account:, memo:, status:)
click to toggle source
rubocop:disable Metrics/ParameterLists
# File lib/aspire_budget/models/transaction.rb, line 22 def initialize(date:, outflow:, inflow:, category:, account:, memo:, status:) @date = date.nil? ? Date.today : Utils.parse_date(date) @outflow = outflow.to_f @inflow = inflow.to_f @category = category @account = account @memo = memo @status = status end
Public Instance Methods
to_row(header)
click to toggle source
rubocop:enable Metrics/ParameterLists
# File lib/aspire_budget/models/transaction.rb, line 33 def to_row(header) header.map do |h| value = send(h) next Utils.serialize_date(value) if h == :date next Utils.serialize_status(value) if h == :status value end end