implemented the method get_old()
This commit is contained in:
parent
e4e1ad9aba
commit
04233362df
@ -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
|
||||
|
@ -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]}"
|
||||
|
@ -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()
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user