class BankAccountStatement::Inputs::HTML::CPBKGB22::Personal::Current::V_2011_05_07

HTML statement parsing for The Co-operative Bank current accounts.

This version is named 2011-05-07 because for quite a while after that time, statements were made available in the same format (also on that date, and perhaps before?). Note, however, that the statement format changed some time around 2015-03-03, for which a different parser should be used. If you experience an error trying to process a recent statement (or rather, a statement downloaded recently, as it could be an old statement), then this is probably why.

Constants

TH

Private Instance Methods

_bank_account_ids() click to toggle source
# File lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/V_2011_05_07.rb, line 38
def _bank_account_ids
  t = @doc.xpath('//table//table//table//td[@class="field"]/h4').first.text
  t.match(/\D(?<bank_id>\d{2}-\d{2}-\d{2})\D+(?<account_id>\d{8})\D/)
end
_clean_amount(str) click to toggle source
# File lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/V_2011_05_07.rb, line 32
def _clean_amount(str)
  s = _clean_str(str)
  m = s[-2..-1] == 'DR' ? -1 : 1
  BigDecimal(s) * m
end
_transaction_rows() click to toggle source
# File lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/V_2011_05_07.rb, line 43
def _transaction_rows
  header = @doc.xpath('//table//table//table//table//table/thead/tr/th'
      ).map(&:text)
  
  @doc.xpath('//table//table//table//table//table/tbody/tr').map { |r|
    Hash[header.zip(r.xpath('td').map(&:text))]
  }
end