Class: StarlingTerminal::Statement
- Inherits:
-
Object
- Object
- StarlingTerminal::Statement
- Defined in:
- lib/starling_terminal/statement.rb
Overview
Builds a Starling statement for output to the terminal
Constant Summary collapse
- TRANSACTIONS_TABLE_HEADINGS =
The headings to be displayed in our table of transactions
['Narrative', 'Amount', 'Date and time', 'Source'].freeze
Instance Method Summary collapse
-
#generate(output: STDOUT) ⇒ #puts
Outputs a complete statement to the provided output.
-
#initialize(access_token: ) ⇒ Statement
constructor
A new instance of Statement.
Constructor Details
#initialize(access_token: ) ⇒ Statement
Returns a new instance of Statement.
14 15 16 17 |
# File 'lib/starling_terminal/statement.rb', line 14 def initialize(access_token: ENV['STARLING_ACCESS_TOKEN']) raise MissingAccessTokenError unless access_token @access_token = access_token end |
Instance Method Details
#generate(output: STDOUT) ⇒ #puts
Outputs a complete statement to the provided output
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/starling_terminal/statement.rb', line 26 def generate(output: STDOUT) output.puts balance_line output.puts pending_transactions_line output.puts available_to_spend_line output.puts "#{transactions_table}\n\n" output rescue Starling::Errors::ApiError => error raise InvalidAccessTokenError if [401, 403].include?(error.status) raise end |