Class: CamtParser::Misc

Inherits:
Object
  • Object
show all
Defined in:
lib/camt_parser/misc.rb

Class Method Summary collapse

Class Method Details

.to_amount(value) ⇒ Object


10
11
12
13
14
# File 'lib/camt_parser/misc.rb', line 10

def to_amount(value)
  return nil if value == nil || value.strip == ''

  BigDecimal(value.gsub(',', '.'))
end

.to_amount_in_cents(value) ⇒ Object


4
5
6
7
8
# File 'lib/camt_parser/misc.rb', line 4

def to_amount_in_cents(value)
  return nil if value == nil || value.strip == ''

  value.gsub(/[,|\.](\d*)/) { $1.ljust(2, '0') }.to_i
end