ExchangeRateVlad 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ExchangeRateVlad.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c67d63c8a00370be0691812d32d5c911c50fd583
|
|
4
|
+
data.tar.gz: 1925c35ba4cb3784da3b92b283b80b061053336f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbd8f34144604cf5a7e473d21167192b255c73944aae83455dabbc5a0f08360f03c98d48a44c6ca070a2cd4b242db28f63b98dfcc19a8d9a8a0b4761b24617b8
|
|
7
|
+
data.tar.gz: 6cbaf4953fb9bd6af5f704336f409d584b8814a1f6fc6f5acbd308f28078c2af7003104e77b26ed7f829239d3d548c307507be41ce35b133c47361ff83007957
|
data/lib/ExchangeRateVlad.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class Converter
|
|
2
2
|
require 'nokogiri'
|
|
3
3
|
@@doc
|
|
4
|
+
@@currencies = ['EUR']
|
|
4
5
|
def init(file)
|
|
5
6
|
if file.start_with?('http://') || file.start_with?('https://')
|
|
6
7
|
require 'open-uri'
|
|
@@ -21,6 +22,13 @@ class Converter
|
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
return true
|
|
25
|
+
end
|
|
26
|
+
def get_currencies()
|
|
27
|
+
c = @@doc.css('Cube Cube').first.css('Cube')
|
|
28
|
+
for x in c
|
|
29
|
+
@@currencies.push(x['currency'])
|
|
30
|
+
end
|
|
31
|
+
return @@currencies
|
|
24
32
|
end
|
|
25
33
|
def at(date, c1, c2)
|
|
26
34
|
d = date.strftime("%Y-%m-%d")
|
|
@@ -30,13 +38,21 @@ class Converter
|
|
|
30
38
|
return -1
|
|
31
39
|
end
|
|
32
40
|
begin
|
|
33
|
-
|
|
41
|
+
if c1 == 'EUR'
|
|
42
|
+
er1 = 1.0
|
|
43
|
+
else
|
|
44
|
+
er1 = r.at_css('[@currency="'+c1+'"]')['rate'].to_f
|
|
45
|
+
end
|
|
34
46
|
rescue
|
|
35
47
|
p 'Something is wrong with this currency: ' + c1
|
|
36
48
|
return -1
|
|
37
49
|
end
|
|
38
50
|
begin
|
|
39
|
-
|
|
51
|
+
if c2 == 'EUR'
|
|
52
|
+
er2 = 1.0
|
|
53
|
+
else
|
|
54
|
+
er2 = r.at_css('[@currency="'+c2+'"]')['rate'].to_f
|
|
55
|
+
end
|
|
40
56
|
rescue
|
|
41
57
|
p 'Something is wrong witht this currency: ' + c2
|
|
42
58
|
return -1
|
|
@@ -47,4 +63,4 @@ end
|
|
|
47
63
|
|
|
48
64
|
require 'date'
|
|
49
65
|
|
|
50
|
-
ExchangeRate = Converter.new
|
|
66
|
+
ExchangeRate = Converter.new
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ExchangeRateVlad
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vlad Otrocol
|
|
@@ -17,7 +17,7 @@ extensions: []
|
|
|
17
17
|
extra_rdoc_files: []
|
|
18
18
|
files:
|
|
19
19
|
- lib/ExchangeRateVlad.rb
|
|
20
|
-
homepage:
|
|
20
|
+
homepage: https://bitbucket.org/vladotrocol/exchangeratevladgem
|
|
21
21
|
licenses:
|
|
22
22
|
- MIT
|
|
23
23
|
metadata: {}
|