Class: MT940::AccountBalance
Overview
60
Direct Known Subclasses
Constant Summary collapse
- CONTENT =
/^(C|D)(\w{6})(\w{3})(\d{1,12},\d{0,2})$/
Constants inherited from Field
Field::DATE, Field::SHORT_DATE
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#balance_type ⇒ Object
readonly
Returns the value of attribute balance_type.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#sign ⇒ Object
readonly
Returns the value of attribute sign.
Attributes inherited from Field
Instance Method Summary collapse
Methods inherited from Field
Constructor Details
This class inherits a constructor from MT940::Field
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
138 139 140 |
# File 'lib/mt940.rb', line 138 def amount @amount end |
#balance_type ⇒ Object (readonly)
Returns the value of attribute balance_type.
138 139 140 |
# File 'lib/mt940.rb', line 138 def balance_type @balance_type end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
138 139 140 |
# File 'lib/mt940.rb', line 138 def currency @currency end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
138 139 140 |
# File 'lib/mt940.rb', line 138 def date @date end |
#sign ⇒ Object (readonly)
Returns the value of attribute sign.
138 139 140 |
# File 'lib/mt940.rb', line 138 def sign @sign end |
Instance Method Details
#parse_content(content) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/mt940.rb', line 142 def parse_content(content) content.match(CONTENT) @balance_type = case @modifier when 'F' :start when 'M' :intermediate end @sign = case $1 when 'C' :credit when 'D' :debit end raw_date = $2 @currency = $3 @amount = parse_amount_in_cents($4) @date = case raw_date when 'ALT', '0' nil when DATE ::Date.new("20#{$1}".to_i, $2.to_i, $3.to_i) end end |