We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4d1ebc7 commit c6b7708Copy full SHA for c6b7708
lib/monetize/parser.rb
@@ -51,11 +51,7 @@ def parse
51
52
negative, num = extract_sign(num)
53
54
- num.chop! if num =~ /[\.|,]$/
55
-
56
- major, minor = extract_major_minor(num)
57
58
- amount = to_big_decimal([major, minor].join(DEFAULT_DECIMAL_MARK))
+ amount = to_big_decimal(normalize_number(num))
59
amount = apply_multiplier(multiplier_exp, amount)
60
amount = apply_sign(negative, amount)
61
@@ -64,6 +60,10 @@ def parse
64
65
private
66
62
63
+ def normalize_number(num)
+ extract_major_minor(num.sub(/[\.|,]$/, "")).join(DEFAULT_DECIMAL_MARK)
+ end
+
67
def to_big_decimal(value)
68
BigDecimal(value)
69
rescue ::ArgumentError => err
0 commit comments