diff --git a/README.md b/README.md index 46ec202..5542077 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ Get the most recent exchange rates **2.** `get_currencies` get list of currency codes and names -**3.** `get_old(date)` *(in development)* +**3.** `get_old(date)` get rates for any given day, where available diff --git a/example.rb b/example.rb index 504d813..21acf96 100644 --- a/example.rb +++ b/example.rb @@ -4,9 +4,11 @@ require 'openexchangerates' currency = OpenExchange.new('586ee899f7eb4f79861589a1f00a8630') cur = JSON.parse(currency.get_latest) +cur_old = JSON.parse(currency.get_old('2010-12-31')) cur_show = 'RUB' -puts "Latest update: #{Time.at(cur['timestamp'])}" -puts "1 USD = #{cur['rates'][cur_show]} \ -(#{JSON.parse(currency.get_currencies)[cur_show]})" +puts "#{Time.at(cur_old['timestamp'])} \n\t1 USD = #{cur['rates'][cur_show]} \ +#{JSON.parse(currency.get_currencies)[cur_show]}" +puts "#{Time.at(cur['timestamp'])} \n\t1 USD = #{cur_old['rates'][cur_show]} \ +#{JSON.parse(currency.get_currencies)[cur_show]}" diff --git a/lib/openexchangerates.rb b/lib/openexchangerates.rb index 78f9d0a..91f672b 100644 --- a/lib/openexchangerates.rb +++ b/lib/openexchangerates.rb @@ -21,6 +21,7 @@ class OpenExchange def get_old(date) # YYYY-MM-DD json = open("#{@@url}historical/#{date}.json?app_id=#{@api_key}", 'User-Agent' => @user_agent).read + return json end def get_currencies() diff --git a/openexchangerates.gemspec b/openexchangerates.gemspec index 3daf46b..b9645e1 100644 --- a/openexchangerates.gemspec +++ b/openexchangerates.gemspec @@ -1,9 +1,9 @@ Gem::Specification.new do |s| s.name = 'openexchangerates' - s.version = '0.0.1' + s.version = '0.1.0' s.date = '2012-12-06' s.summary = 'Implementation API openexchangerates.org on Ruby' - s.description = 'Implementation API openexchangerates.org on Ruby' + s.description = '...' s.authors = ['Alexander Popov'] s.email = ['iiiypuk@iiiypuk.me'] s.homepage = 'https://github.com/IIIypuk/openexchangerates'