class CamtParser::AccountBalance

Public Class Methods

new(amount, currency, date, credit = false) click to toggle source

@param amount [String] @param currency [String] @param date [String] @param credit [Boolean]

# 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

Public Instance Methods

amount() click to toggle source

@return [BigDecimal]

# File lib/camt_parser/general/account_balance.rb, line 36
def amount
  CamtParser::Misc.to_amount(@amount)
end
amount_in_cents() click to toggle source

@return [Integer]

# File lib/camt_parser/general/account_balance.rb, line 41
def amount_in_cents
  CamtParser::Misc.to_amount_in_cents(@amount)
end
credit?() click to toggle source

@return [Boolean]

# File lib/camt_parser/general/account_balance.rb, line 31
def credit?
  @credit
end
currency() click to toggle source

@return [String]

# File lib/camt_parser/general/account_balance.rb, line 16
def currency
  @currency
end
date() click to toggle source

@return [Date]

# File lib/camt_parser/general/account_balance.rb, line 21
def date
  Date.parse @date
end
sign() click to toggle source

@return [Integer] either 1 or -1

# File lib/camt_parser/general/account_balance.rb, line 26
def sign
  credit? ? 1 : -1
end
signed_amount() click to toggle source

@return [BigDecimal]

# File lib/camt_parser/general/account_balance.rb, line 46
def signed_amount
  amount * sign
end
to_h() click to toggle source

@return [Hash{String => BigDecimal, Integer}]

# File lib/camt_parser/general/account_balance.rb, line 51
def to_h
  {
    'amount' => amount,
    'amount_in_cents' => amount_in_cents,
    'sign' => sign
  }
end