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.

Parameters:



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

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

Instance Method Details

#amountBigDecimal

Returns:

  • (BigDecimal)


36
37
38
# File 'lib/camt_parser/general/account_balance.rb', line 36

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

#amount_in_centsInteger

Returns:

  • (Integer)


41
42
43
# File 'lib/camt_parser/general/account_balance.rb', line 41

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

#credit?Boolean

Returns:

  • (Boolean)


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

def credit?
  @credit
end

#currencyString

Returns:



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

def currency
  @currency
end

#dateDate

Returns:

  • (Date)


21
22
23
# File 'lib/camt_parser/general/account_balance.rb', line 21

def date
  Date.parse @date
end

#signInteger

Returns either 1 or -1.

Returns:

  • (Integer)

    either 1 or -1



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

def sign
  credit? ? 1 : -1
end

#signed_amountBigDecimal

Returns:

  • (BigDecimal)


46
47
48
# File 'lib/camt_parser/general/account_balance.rb', line 46

def signed_amount
  amount * sign
end

#to_hHash{String => BigDecimal, Integer}

Returns:

  • (Hash{String => BigDecimal, Integer})


51
52
53
54
55
56
57
# File 'lib/camt_parser/general/account_balance.rb', line 51

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