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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b824e4e9b07c772c3d6afd9f2e070e1a71e163b
|
4
|
+
data.tar.gz: 9f6f5039b23167c3d6bcc46b4461301ea2e54cfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddfca37de77e6e0c3ce076eac27a45cd3555c33bba2567ecac0e2a69049712d5355c173c18b8eb5f388d2f8a54c3d53c04ff4606fc9dc22dd02f5b500fac02b3
|
7
|
+
data.tar.gz: bee1c44bf22ee58a968f2dd15263eb798347654d2738323668f6ff05b2633aa48205cb16862c22266b682de1e4cca22780951bdbe1387daf45e2ef3cc32ccfd0
|
data/lib/historic_bank_rates.rb
CHANGED
@@ -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
|
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.
|
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:
|