Class: SepaFileParser::AccountBalance
- Inherits:
-
Object
- Object
- SepaFileParser::AccountBalance
- Defined in:
- lib/sepa_file_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.
10 11 12 13 14 15 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 10 def initialize(amount, currency, date, credit = false) @amount = amount @currency = currency @date = date @credit = credit end |
Instance Method Details
#amount ⇒ BigDecimal
38 39 40 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 38 def amount SepaFileParser::Misc.to_amount(@amount) end |
#amount_in_cents ⇒ Integer
43 44 45 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 43 def amount_in_cents SepaFileParser::Misc.to_amount_in_cents(@amount) end |
#credit? ⇒ Boolean
33 34 35 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 33 def credit? @credit end |
#currency ⇒ String
18 19 20 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 18 def currency @currency end |
#date ⇒ Date
23 24 25 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 23 def date Date.parse @date end |
#sign ⇒ Integer
Returns either 1 or -1.
28 29 30 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 28 def sign credit? ? 1 : -1 end |
#signed_amount ⇒ BigDecimal
48 49 50 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 48 def signed_amount amount * sign end |
#to_h ⇒ Hash{String => BigDecimal, Integer}
53 54 55 56 57 58 59 |
# File 'lib/sepa_file_parser/general/account_balance.rb', line 53 def to_h { 'amount' => amount, 'amount_in_cents' => amount_in_cents, 'sign' => sign } end |