implemented the method get_old()

This commit is contained in:
Alexander Popov 2013-12-06 06:47:08 +04:00
parent e4e1ad9aba
commit 04233362df
4 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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]}"

View File

@ -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()

View File

@ -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'