Class: AspireBudget::Worksheets::Transactions
- Inherits:
-
WorksheetBase
- Object
- WorksheetBase
- AspireBudget::Worksheets::Transactions
- Defined in:
- lib/aspire_budget/worksheets/transactions.rb
Direct Known Subclasses
Constant Summary collapse
- WS_TITLE =
'Transactions'
Instance Method Summary collapse
-
#all ⇒ Array<AspireBudget::Transaction>
All transactions.
-
#insert(record, sync: true) ⇒ AspireBudget::Transaction
Inserts a transaction to the spreadsheet.
Methods inherited from WorksheetBase
#dirty?, #initialize, instance
Constructor Details
This class inherits a constructor from AspireBudget::Worksheets::WorksheetBase
Instance Method Details
#all ⇒ Array<AspireBudget::Transaction>
Returns all transactions.
12 13 14 15 16 |
# File 'lib/aspire_budget/worksheets/transactions.rb', line 12 def all rows.map do |row| klass.from_row(header, row) end end |
#insert(record, sync: true) ⇒ AspireBudget::Transaction
Inserts a transaction to the spreadsheet. Accepts either a transaction record or a hash (that is passed to the transaction initializer)
23 24 25 26 27 28 29 |
# File 'lib/aspire_budget/worksheets/transactions.rb', line 23 def insert(record, sync: true) record = klass.new(**record) if record.is_a?(Hash) row = record.to_row(header) ws.update_cells(*next_row_col, [row]) ws.synchronize if sync record end |