Module: Outbanker::MoneyStringParser
- Included in:
- StatementLine
- Defined in:
- lib/outbanker/money_string_parser.rb
Instance Method Summary collapse
Instance Method Details
#to_cents(string) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/outbanker/money_string_parser.rb', line 3 def to_cents(string) matches = string.match(/(?<separator>\.|\,)(?<cents>[0-9]{1,2})\Z/) if !matches string.to_i * 100 elsif matches[:cents].length == 1 string.gsub(matches[:separator], '').to_i * 10 elsif matches[:cents].length == 2 string.gsub(matches[:separator], '').to_i end end |