Class: StarlingTerminal::TransactionRow

Inherits:
Object
  • Object
show all
Defined in:
lib/starling_terminal/transaction_row.rb

Overview

A presenter to convert Starling::Resources::TransactionResource instances to presented rows for our transactions table

Class Method Summary collapse

Class Method Details

.present(transaction) ⇒ Array<String>

Converts a Starling Bank transaction into a row to be displayed in our transactions table

Parameters:

  • transaction (Starling::Resources::TransactionResource)

    the transaction resource returned from the Starling Bank API

Returns:

  • (Array<String>)

    a row suitable for presentation through `Terminal::Table`


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/starling_terminal/transaction_row.rb', line 15

def self.present(transaction)
  amount = transaction.amount

  [
    transaction.narrative,
    Utils.float_to_currency(amount, currency: transaction.currency)
         .colorize(Utils.colour_for_amount(amount)),
    Utils.present_time(transaction.created),
    transaction.source.to_s
  ]
end