historic_bank_rates 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb69f3df288e11540ed20ab70234a9611f4c9a66
4
- data.tar.gz: 2b23307ca7fe34e25bf30673b5dd3e0cac0e68c9
3
+ metadata.gz: 0b824e4e9b07c772c3d6afd9f2e070e1a71e163b
4
+ data.tar.gz: 9f6f5039b23167c3d6bcc46b4461301ea2e54cfb
5
5
  SHA512:
6
- metadata.gz: b94aeb180adee312e34a98b0f8c0887189648f39ca7b52bf0ac21117ad683cedf6e723526d2dbda8fe0e3111f2569fc0825e8fdc8b3fe8a572772a23380e9377
7
- data.tar.gz: ebe13eb2c7b4e8630481d0671698a3a87b3301985b71547263a842bec2401d1554669eb59577603f7b9f67bcd846dd804334351b592cef30132e66ca8948e0b8
6
+ metadata.gz: ddfca37de77e6e0c3ce076eac27a45cd3555c33bba2567ecac0e2a69049712d5355c173c18b8eb5f388d2f8a54c3d53c04ff4606fc9dc22dd02f5b500fac02b3
7
+ data.tar.gz: bee1c44bf22ee58a968f2dd15263eb798347654d2738323668f6ff05b2633aa48205cb16862c22266b682de1e4cca22780951bdbe1387daf45e2ef3cc32ccfd0
@@ -1,5 +1,5 @@
1
1
  require_relative 'historic_bank_rates/rates'
2
2
 
3
3
  module HistoricBankRates
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
@@ -0,0 +1,43 @@
1
+ require_relative 'rate_scraper.rb'
2
+
3
+ module HistoricBankRates
4
+ module BankScrapers
5
+ class RwandaNationalBank < HistoricBankRates::BankScrapers::RateScraper
6
+
7
+ def base_currency
8
+ 'RWF'
9
+ end
10
+
11
+ private
12
+
13
+ def rates
14
+ response = Net::HTTP.post_form(URI(form_url), form_params)
15
+ dom = Nokogiri::HTML(response.body)
16
+ rows = dom.css(element_matcher)
17
+
18
+ Hash[(0...rows.length).step(4).map do |index|
19
+ currency = rows[index].css(':nth-child(1)').text
20
+ next if currency.empty?
21
+ avrg = rows[index+1].text.delete(',')
22
+ next if avrg.empty?
23
+
24
+ [currency, Float(avrg)] rescue nil
25
+ end.compact]
26
+ end
27
+
28
+ def form_url
29
+ @form_url ||= 'http://www.bnr.rw/index.php?id=89'
30
+ end
31
+
32
+ def form_params
33
+ { 'tx_excratearch_excratearch[date]' => start_date.strftime('%d-%m-%Y'), #12-07-2016
34
+ 'tx_excratearch_excratearch[getHistory]' => 'Get+History'
35
+ }
36
+ end
37
+
38
+ def element_matcher
39
+ 'tbody > tr > td'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,6 +1,7 @@
1
1
  require 'date'
2
2
  require_relative 'bank_scrapers/central_bank_of_kenya'
3
3
  require_relative 'bank_scrapers/bank_of_tanzania'
4
+ require_relative 'bank_scrapers/rwanda_national_bank'
4
5
 
5
6
  module HistoricBankRates
6
7
  class MissingRates < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: historic_bank_rates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Donkin
@@ -97,6 +97,7 @@ files:
97
97
  - lib/historic_bank_rates/bank_scrapers/bank_of_tanzania.rb
98
98
  - lib/historic_bank_rates/bank_scrapers/central_bank_of_kenya.rb
99
99
  - lib/historic_bank_rates/bank_scrapers/rate_scraper.rb
100
+ - lib/historic_bank_rates/bank_scrapers/rwanda_national_bank.rb
100
101
  - lib/historic_bank_rates/rates.rb
101
102
  homepage: http://github.com/plugintheworld/historic_bank_rates
102
103
  licenses: