Class: CamtParser::AccountBalance

Inherits:
Object
  • Object
show all
Defined in:
lib/camt_parser/general/account_balance.rb

Instance Method Summary collapse

Constructor Details

#initialize(amount, currency, date, credit = false) ⇒ AccountBalance

Returns a new instance of AccountBalance.



4
5
6
7
8
9
# File 'lib/camt_parser/general/account_balance.rb', line 4

def initialize(amount, currency, date, credit = false)
  @amount = amount
  @currency = currency
  @date = date
  @credit = credit
end

Instance Method Details

#amountObject



27
28
29
# File 'lib/camt_parser/general/account_balance.rb', line 27

def amount
  CamtParser::Misc.to_amount(@amount)
end

#amount_in_centsObject



31
32
33
# File 'lib/camt_parser/general/account_balance.rb', line 31

def amount_in_cents
  CamtParser::Misc.to_amount_in_cents(@amount)
end

#credit?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/camt_parser/general/account_balance.rb', line 23

def credit?
  @credit
end

#currencyObject



11
12
13
# File 'lib/camt_parser/general/account_balance.rb', line 11

def currency
  @currency
end

#dateObject



15
16
17
# File 'lib/camt_parser/general/account_balance.rb', line 15

def date
  Date.parse @date
end

#signObject



19
20
21
# File 'lib/camt_parser/general/account_balance.rb', line 19

def sign
  credit? ? 1 : -1
end

#to_hObject



35
36
37
38
39
40
41
# File 'lib/camt_parser/general/account_balance.rb', line 35

def to_h
  {
    'amount' => amount,
    'amount_in_cents' => amount_in_cents,
    'sign' => sign
  }
end