currency_quote 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/currency_quote/currency.rb +9 -9
- data/lib/currency_quote/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 403e17ea3aacaa228865ab8672a3187971105d9e9ca988ba872151078564896f
|
4
|
+
data.tar.gz: d8d0b773152e7fffe3013a56f70def54d2d3d6d2eb8959d3d1e07da73a91e5bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ac6aa4c42c94321596240aacb69015e4e4f469c0e1246ef6f8fc342e256d2e6f63bc884fc4422aa3cf678b65f345e4d690bbae75c5fe460fb460ca3cdfbcce
|
7
|
+
data.tar.gz: 7a66cada67f6c9ae1369d8870afc650dc298b095a97efc349ebbc01b0c365138e8e402442b347afa9b72903b667119e3749a0ff1c8920ef669fa652fdfebd915
|
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@ class CurrencyQuote::Currency
|
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'date'
|
5
5
|
|
6
|
-
attr_accessor :currency, :date, :dolar, :doc, :sell, :buy
|
6
|
+
attr_accessor :currency, :date, :dolar, :doc, :sell, :buy, :quote
|
7
7
|
|
8
8
|
BASE_URL = "https://www.bcra.gob.ar/publicacionesestadisticas/Cotizaciones_por_fecha_2.asp"
|
9
9
|
|
@@ -15,8 +15,7 @@ class CurrencyQuote::Currency
|
|
15
15
|
|
16
16
|
def get_quotation
|
17
17
|
if currency == "Dolar Estadounidense"
|
18
|
-
|
19
|
-
else
|
18
|
+
get_dolar_quotation
|
20
19
|
get_dolar_quotation
|
21
20
|
make_get_to_bcra
|
22
21
|
get_currency_quotation
|
@@ -39,17 +38,18 @@ class CurrencyQuote::Currency
|
|
39
38
|
data = @doc.css("td").map(&:text).collect(&:strip!)
|
40
39
|
index = data.index(currency)
|
41
40
|
if index
|
42
|
-
|
43
|
-
quote =
|
44
|
-
|
45
|
-
@
|
41
|
+
pass = data[index + 1].gsub(",", ".").to_f
|
42
|
+
@quote = data[index + 2].gsub(",", ".").to_f
|
43
|
+
pass = 1.0 if pass == 0
|
44
|
+
@sell = (dolar.sell * pass).to_f
|
45
|
+
@buy = (dolar.buy * pass).to_f
|
46
46
|
else
|
47
47
|
@sell = @buy = 0
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def struct
|
52
|
-
s = Struct.new(:currency, :date, :sell, :buy)
|
53
|
-
s.new(currency, date, sell, buy)
|
52
|
+
s = Struct.new(:currency, :date, :sell, :buy, :quote)
|
53
|
+
s.new(currency, date, sell, buy, quote)
|
54
54
|
end
|
55
55
|
end
|