Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

renamed Money::Bank to Money::BaseBank

  • Loading branch information...
commit 2fd9b41ae19a4916c0d12e8debefd4a2c4a660c4 1 parent 3617c39
@semmons99 semmons99 authored
View
8 lib/money/bank.rb → lib/money/base_bank.rb
@@ -1,14 +1,14 @@
require 'thread'
class Money
- class Bank
+ class BaseBank
class UnknownRate < StandardError; end
def self.instance
@@singleton
end
- @@singleton = Bank.new
+ @@singleton = BaseBank.new
def initialize(&block)
@rates = {}
@@ -23,7 +23,7 @@ def exchange(cents, from_currency, to_currency, &block)
rate = get_rate(from_currency, to_currency)
unless rate
- raise Money::Bank::UnknownRate, "No conversion rate known for '#{from_currency}' -> '#{to_currency}'"
+ raise Money::BaseBank::UnknownRate, "No conversion rate known for '#{from_currency}' -> '#{to_currency}'"
end
_from_currency_ = Currency.wrap(from_currency)
_to_currency_ = Currency.wrap(to_currency)
@@ -41,7 +41,7 @@ def exchange_with(from, to_currency, &block)
rate = get_rate(from.currency, to_currency)
unless rate
- raise Money::Bank::UnknownRate, "No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'"
+ raise Money::BaseBank::UnknownRate, "No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'"
end
_to_currency_ = Currency.wrap(to_currency)
View
4 lib/money/variable_exchange_bank.rb
@@ -1,4 +1,4 @@
-require 'money/bank'
+require 'money/base_bank'
# Class for aiding in exchanging money between different currencies.
# By default, the Money class uses an object of this class (accessible through
@@ -18,7 +18,7 @@
# bank.exchange(100_00, "USD", "CAD") # => 80
#
class Money
- class VariableExchangeBank < Bank
+ class VariableExchangeBank < BaseBank
@@singleton = VariableExchangeBank.new
# Registers a conversion rate. +from+ and +to+ are both currency names or
View
12 test/bank_spec.rb → test/base_bank_spec.rb
@@ -1,11 +1,11 @@
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'money/currency'
-require 'money/bank'
+require 'money/base_bank'
-describe Money::Bank do
+describe Money::BaseBank do
describe '#new without block' do
before :each do
- @bank = Money::Bank.new
+ @bank = Money::BaseBank.new
end
describe '#rate_key_for' do
@@ -129,7 +129,7 @@
end
it 'should raise an UnknownRate exception when an unknown rate is requested' do
- lambda{@bank.exchange(100, 'USD', 'JPY')}.should raise_exception(Money::Bank::UnknownRate)
+ lambda{@bank.exchange(100, 'USD', 'JPY')}.should raise_exception(Money::BaseBank::UnknownRate)
end
it 'should accept a custom truncation method' do
@@ -164,7 +164,7 @@
end
it 'should raise an UnknownRate exception when an unknown rate is requested' do
- lambda{@bank.exchange_with(Money.new(100, 'USD'), 'JPY')}.should raise_exception(Money::Bank::UnknownRate)
+ lambda{@bank.exchange_with(Money.new(100, 'USD'), 'JPY')}.should raise_exception(Money::BaseBank::UnknownRate)
end
it 'should accept a custom truncation method' do
@@ -177,7 +177,7 @@
describe '#new with &block' do
before :each do
proc = Proc.new{|n| n.ceil}
- @bank = Money::Bank.new(&proc)
+ @bank = Money::BaseBank.new(&proc)
@bank.send(:set_rate, 'USD', 'EUR', 1.33)
end
View
4 test/variable_exchange_bank_spec.rb
@@ -35,9 +35,9 @@
@bank.exchange(500_00, "EUR", "YEN").should == 6131573
end
- it "raises Money::Bank::UnknownRate upon conversion if the conversion rate is unknown" do
+ it "raises Money::BaseBank::UnknownRate upon conversion if the conversion rate is unknown" do
block = lambda { @bank.exchange(10, "USD", "EUR") }
- block.should raise_error(Money::Bank::UnknownRate)
+ block.should raise_error(Money::BaseBank::UnknownRate)
end
describe '#exchange' do
Please sign in to comment.
Something went wrong with that request. Please try again.