class AspireBudget::Models::CategoryTransfer

Attributes

amount[R]
date[R]
from[R]
memo[R]
to[R]

Public Class Methods

from_row(header, row) click to toggle source
# File lib/aspire_budget/models/category_transfer.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])
  end

  new(**params)
end
new(date:, amount:, from:, to:, memo:) click to toggle source
# File lib/aspire_budget/models/category_transfer.rb, line 20
def initialize(date:, amount:, from:, to:, memo:)
  @date = date.nil? ? Date.today : Utils.parse_date(date)
  @amount = amount.to_f
  @from = from || 'Available to Budget'
  @to = to
  @memo = memo
end

Public Instance Methods

to_row(header) click to toggle source
# File lib/aspire_budget/models/category_transfer.rb, line 28
def to_row(header)
  header.map do |h|
    value = send(h)
    next Utils.serialize_date(value) if h == :date

    value
  end
end