Class: AspireBudget::Models::CategoryTransfer
- Inherits:
-
Object
- Object
- AspireBudget::Models::CategoryTransfer
- Defined in:
- lib/aspire_budget/models/category_transfer.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#memo ⇒ Object
readonly
Returns the value of attribute memo.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(date:, amount:, from:, to:, memo:) ⇒ CategoryTransfer
constructor
A new instance of CategoryTransfer.
- #to_row(header) ⇒ Object
Constructor Details
#initialize(date:, amount:, from:, to:, memo:) ⇒ CategoryTransfer
Returns a new instance of CategoryTransfer.
20 21 22 23 24 25 26 |
# 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 |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
8 9 10 |
# File 'lib/aspire_budget/models/category_transfer.rb', line 8 def amount @amount end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
8 9 10 |
# File 'lib/aspire_budget/models/category_transfer.rb', line 8 def date @date end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
8 9 10 |
# File 'lib/aspire_budget/models/category_transfer.rb', line 8 def from @from end |
#memo ⇒ Object (readonly)
Returns the value of attribute memo.
8 9 10 |
# File 'lib/aspire_budget/models/category_transfer.rb', line 8 def memo @memo end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
8 9 10 |
# File 'lib/aspire_budget/models/category_transfer.rb', line 8 def to @to end |
Class Method Details
.from_row(header, row) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# 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 |
Instance Method Details
#to_row(header) ⇒ Object
28 29 30 31 32 33 34 35 |
# 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 |