currencies 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ If you are tracking any kind of assets the currencies gem is for you. It contain
6
6
  Installation
7
7
  ------------
8
8
 
9
- Countries is hosted on GemCutter, so simply run the following:
9
+ Currencies is hosted on GemCutter, so simply run the following:
10
10
 
11
11
  gem sources -a http://gemcutter.org
12
12
  sudo gem install currencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{currencies}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hexorx"]
12
- s.date = %q{2010-02-18}
12
+ s.date = %q{2010-02-19}
13
13
  s.description = %q{If you are tracking any kind of assets the currencies gem is for you. It contains every currency in the ISO 4217 standard and allows you to add your own as well. So if you decide to take sparkly buttons as a form of payment you can use currencies to display the shiny button unicode symbol ☼ (disclaimer: ☼ may not look like a shiny button to everyone.) when used with something like the money gem. Speaking of the money gem, currencies gives you an ExchangeBank that the money gem can use to convert from one currency to another. There are plans to have ExchangeRate provider plugin system. Right now the rates are either set manually or pulled from Yahoo Finance.}
14
14
  s.email = %q{hexorx@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -15,6 +15,10 @@ class Currency
15
15
  @exchange_rate = opts['exchange_rate'].to_f if opts['exchange_rate']
16
16
  end
17
17
 
18
+ def [](value)
19
+ self.instance_variable_get("@#{value}")
20
+ end
21
+
18
22
  def exchange_rate
19
23
  @exchange_rate = nil unless @exchange_currency == Currency.base_currency
20
24
  @exchange_rate ||= load_exchange_rate
@@ -42,7 +46,7 @@ class Currency
42
46
  def self.from_code(code)
43
47
  self.currencies[code.to_s.upcase]
44
48
  end
45
-
49
+
46
50
  def self.add(new_currency)
47
51
  self.currencies ||= {}
48
52
  self.currencies[new_currency.code] = new_currency
@@ -9,16 +9,28 @@ describe Currency do
9
9
  it 'should return code' do
10
10
  @usd.code.should == 'USD'
11
11
  @gbp.code.should == 'GBP'
12
+ @usd[:code].should == 'USD'
13
+ @gbp[:code].should == 'GBP'
14
+ @usd['code'].should == 'USD'
15
+ @gbp['code'].should == 'GBP'
12
16
  end
13
17
 
14
18
  it 'should return symbol' do
15
19
  @usd.symbol.should == '$'
16
20
  @gbp.symbol.should == '£'
21
+ @usd[:symbol].should == '$'
22
+ @gbp[:symbol].should == '£'
23
+ @usd['symbol'].should == '$'
24
+ @gbp['symbol'].should == '£'
17
25
  end
18
26
 
19
27
  it 'should return name' do
20
28
  @usd.name.should == 'Dollars'
21
29
  @gbp.name.should == 'Pounds'
30
+ @usd[:name].should == 'Dollars'
31
+ @gbp[:name].should == 'Pounds'
32
+ @usd['name'].should == 'Dollars'
33
+ @gbp['name'].should == 'Pounds'
22
34
  end
23
35
 
24
36
  describe 'from_code' do
@@ -45,7 +57,6 @@ describe Currency do
45
57
  describe 'exchange_rate' do
46
58
  it 'should return a float' do
47
59
  Currency.from_code('GBP').exchange_rate.should be_a(Float)
48
- puts Currency.from_code('GBP').exchange_rate
49
60
  end
50
61
 
51
62
  it 'should have an exchange rate of 1.0 for the base currency' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hexorx
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-18 00:00:00 -07:00
12
+ date: 2010-02-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency