Before running; It will be necessary to have installed the following gems;
gem install whenever
gem install nokogiri
To use ExchangeRate, place the ExchangeRate folder within the base directory of your project.
The reference file will initially be out of date and this will be updated by the scheduled task at 3.15pm, however you may want to update it to start with. This can be done by running "ruby ExchangeRate/lib/fx_create.rb"
ExchangeRate has been set up to use the whenever gem to run a daily task (cron). At first it will be necessary to update the crontab. To do this, run the following command at the base of the ExchangeRate directory;
'whenever --update-crontab'
To use the ExchangeRate class, require it in like this;
require_relative './ExchangeRate/lib/exchange_rate'
Call the 'at' method like this; ExchangeRate.at(date, base currency, counter currency)
The date parameter may be either a Date object like Date.today or a String which should be in the format 'YYYY-MM-DD'
The base currency and counter currency parameters should be a string matching (case insensitive) any of these currency abbreviations:-
"USD", "JPY", "BGN",
"CZK", "DKK", "GBP",
"HUF", "PLN", "RON",
"SEK", "CHF", "ISK",
"NOK", "HRK", "RUB",
"TRY", "AUD", "BRL",
"CAD", "CNY", "HKD",
"IDR", "ILS", "INR",
"KRW", "MXN", "MYR",
"NZD", "PHP", "SGD",
"THB", "ZAR"
To alter the time that this cron job is carried out you may edit the schedule.rb file in the config folder. Each time you edit the schedule.rb file, you will need to enter this command in the terminal at the base of the ExchangeRate directory to update the crontab; 'whenever --update-crontab' It may be helpful to read the ReadMe at https://github.com/javan/whenever to see how cron tasks may be configured using the whenever gem.