Class: CamtParser::Misc
- Inherits:
-
Object
- Object
- CamtParser::Misc
- Defined in:
- lib/camt_parser/misc.rb
Class Method Summary collapse
Class Method Details
.to_amount(value) ⇒ BigDecimal?
18 19 20 21 22 |
# File 'lib/camt_parser/misc.rb', line 18 def to_amount(value) return nil if value == nil || value.strip == '' BigDecimal(value.tr(',', '.')) end |
.to_amount_in_cents(value) ⇒ Integer?
7 8 9 10 11 12 13 14 |
# File 'lib/camt_parser/misc.rb', line 7 def to_amount_in_cents(value) return nil if value == nil || value.strip == '' # Using dollars and cents as representation for parts before and after the decimal separator dollars, cents = value.split(/,|\./) cents ||= '0' format('%s%s', dollars, cents.ljust(2, '0')).to_i end |