# File lib/money/money/parsing.rb, line 34 def parse(input, currency = nil) i = input.to_s # Get the currency. m = i.scan /([A-Z]{2,3})/ c = m[0] ? m[0][0] : nil # check that currency passed and embedded currency are the same, # and negotiate the final currency if currency.nil? and c.nil? currency = Money.default_currency elsif currency.nil? currency = c elsif c.nil? currency = currency elsif currency != c # TODO: ParseError raise ArgumentError, "Mismatching Currencies" end currency = Money::Currency.wrap(currency) cents = extract_cents(i, currency) new(cents, currency) end