Class: CamtParser::AccountBalance
- Inherits:
-
Object
- Object
- CamtParser::AccountBalance
- Defined in:
- lib/camt_parser/general/account_balance.rb
Instance Method Summary collapse
- #amount ⇒ BigDecimal
- #amount_in_cents ⇒ Integer
- #credit? ⇒ Boolean
- #currency ⇒ String
- #date ⇒ Date
-
#initialize(amount, currency, date, credit = false) ⇒ AccountBalance
constructor
A new instance of AccountBalance.
-
#sign ⇒ Integer
Either 1 or -1.
- #signed_amount ⇒ BigDecimal
- #to_h ⇒ Hash{String => BigDecimal, Integer}
Constructor Details
#initialize(amount, currency, date, credit = false) ⇒ AccountBalance
Returns a new instance of AccountBalance.
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
#amount ⇒ BigDecimal
36 37 38 |
# File 'lib/camt_parser/general/account_balance.rb', line 36 def amount CamtParser::Misc.to_amount(@amount) end |
#amount_in_cents ⇒ 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
31 32 33 |
# File 'lib/camt_parser/general/account_balance.rb', line 31 def credit? @credit end |
#currency ⇒ String
16 17 18 |
# File 'lib/camt_parser/general/account_balance.rb', line 16 def currency @currency end |
#date ⇒ Date
21 22 23 |
# File 'lib/camt_parser/general/account_balance.rb', line 21 def date Date.parse @date end |
#sign ⇒ Integer
Returns either 1 or -1.
26 27 28 |
# File 'lib/camt_parser/general/account_balance.rb', line 26 def sign credit? ? 1 : -1 end |
#signed_amount ⇒ BigDecimal
46 47 48 |
# File 'lib/camt_parser/general/account_balance.rb', line 46 def signed_amount amount * sign end |
#to_h ⇒ 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 |