class Money::Parser::Simple
def parse(input, currency, strict: false)
-
(Money, nil)
-
Parameters:
-
strict
(Boolean
) -- -
currency
(String, Money::Currency
) -- -
input
(String
) --
def parse(input, currency, strict: false) currency = Money::Helpers.value_to_currency(currency) return unless currency coerced = input.to_s if SIGNED_DECIMAL_MATCHER.match?(coerced) && (amount = BigDecimal(coerced, exception: false)) Money.new(amount, currency) elsif strict raise ArgumentError, "unable to parse input=\"#{input}\" currency=\"#{currency}\"" end end