Class: SepaFileParser::Misc
- Inherits:
-
Object
- Object
- SepaFileParser::Misc
- Defined in:
- lib/sepa_file_parser/misc.rb
Class Method Summary collapse
Class Method Details
.to_amount(value) ⇒ BigDecimal?
20 21 22 23 24 |
# File 'lib/sepa_file_parser/misc.rb', line 20 def to_amount(value) return nil if value == nil || value.strip == '' BigDecimal(value.tr(',', '.')) end |
.to_amount_in_cents(value) ⇒ Integer?
9 10 11 12 13 14 15 16 |
# File 'lib/sepa_file_parser/misc.rb', line 9 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 |