No commit activity in last 3 years
No release in over 3 years
Wraps a simple scraper to retrieve the historic exchange rates of specific banks. Returns the average (between buy and sell) rates for any day specified (if date isn't specified it defaults to yesterday).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.6
 Project Readme

Historic Bank Rates

Build Status

Wraps a simple scraper to retrieve the historic exchange rates. Returns the average rates for yesterday or any day specified and supported by the Central Bank of Kenya.

Install

Add this line to your application's Gemfile:

gem 'historic_bank_rates'

And then execute:

$ bundle

Or install it yourself as:

$ gem install historic_bank_rates

Usage

Initialize (NOTE: the date used can affect the success of the import! method)

scraper = HistoricBankRates::BankScrapers::CentralBankOfKenya.new
hbr = HistoricBankRates::Rates.new(scraper, Date.new(2016, 05, 30))
hbr.import! # => true

import! returns true if rates have been found. Might also throw HTTP errors. It will also return false when requesting rates for weekend days.

Update an instance's import_date and rerun the import process:

hbr.import!(Date.new(2015, 06, 30)) # => true

Retrieve a specific rate

hbr.rate('KES', 'EUR') # => 112.2322

Get all available currencies:

hbr.currencies # => ['ZAR', 'USD', 'EUR', 'RWF'… ]

Get all rates

hbr.rates # => { 'ZAR'=>6.4373, 'USD'=>100.6606, … }

Legal

The author of this gem is not affiliated with any of the banks referenced/scraped by the gem.

License

MIT, see LICENSE file

No Warranty

The Software is provided "as is" without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.