Skip to content

Commit

Permalink
Merge pull request RubyMoney#494 from epidemian/variable-exchange-doc…
Browse files Browse the repository at this point in the history
…-fix

Use Money.new instead of Numeric#to_money in VariableExchange docs
  • Loading branch information
semmons99 committed Feb 6, 2015
2 parents b9fdcb0 + ab5530d commit 3479b96
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/money/bank/variable_exchange.rb
Expand Up @@ -20,14 +20,14 @@ class UnknownRateFormat < StandardError; end
# bank.add_rate("USD", "CAD", 1.24515)
# bank.add_rate("CAD", "USD", 0.803115)
#
# c1 = 100_00.to_money("USD")
# c2 = 100_00.to_money("CAD")
# c1 = Money.new(100_00, "USD")
# c2 = Money.new(100_00, "CAD")
#
# # Exchange 100 USD to CAD:
# bank.exchange_with(c1, "CAD") #=> #<Money @fractional=1245150>
# bank.exchange_with(c1, "CAD") #=> #<Money fractional:12451 currency:CAD>
#
# # Exchange 100 CAD to USD:
# bank.exchange_with(c2, "USD") #=> #<Money @fractional=803115>
# bank.exchange_with(c2, "USD") #=> #<Money fractional:8031 currency:USD>
class VariableExchange < Base

attr_reader :rates, :mutex
Expand Down Expand Up @@ -76,14 +76,14 @@ def marshal_load(arr)
# bank.add_rate("USD", "CAD", 1.24515)
# bank.add_rate("CAD", "USD", 0.803115)
#
# c1 = 100_00.to_money("USD")
# c2 = 100_00.to_money("CAD")
# c1 = Money.new(100_00, "USD")
# c2 = Money.new(100_00, "CAD")
#
# # Exchange 100 USD to CAD:
# bank.exchange_with(c1, "CAD") #=> #<Money @fractional=1245150>
# bank.exchange_with(c1, "CAD") #=> #<Money fractional:12451 currency:CAD>
#
# # Exchange 100 CAD to USD:
# bank.exchange_with(c2, "USD") #=> #<Money @fractional=803115>
# bank.exchange_with(c2, "USD") #=> #<Money fractional:8031 currency:USD>
def exchange_with(from, to_currency, &block)
to_currency = Currency.wrap(to_currency)
if from.currency == to_currency
Expand Down

0 comments on commit 3479b96

Please sign in to comment.