dolar-bna 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dolar/bna/exchange.rb +17 -2
- data/lib/dolar/bna/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: 687a7d90ef5128b874b22f4a9cae467ef2e8259824f0e36a2a64f519f27a37b6
|
4
|
+
data.tar.gz: dd4c33a15f0f848193a0e741af9ac334c406e0392ddf48e8bc00b5abeaf22acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf080ba8a7e770182c8e50092775cb6e6504dc69ef2a0c05f1bfb6d4f1586631ed8a60be82be81e868c903a395c0c0362b146720629b2f107eda36a49a481c5
|
7
|
+
data.tar.gz: 41f9a8a64413d712c5d52e1fc627d9612d1458f1651ec6aed904fbb77ea798c2f0d72ab9b4df2defeefffb28cab6952164efc338ba9d8e669289ba9e06642829
|
data/lib/dolar/bna/exchange.rb
CHANGED
@@ -38,8 +38,8 @@ module Dolar
|
|
38
38
|
def variation_billete
|
39
39
|
begin
|
40
40
|
Timeout.timeout(15) do
|
41
|
-
today_dolar =
|
42
|
-
yesterday_dolar =
|
41
|
+
today_dolar = check_cotization_for_variations("Billete", @fecha)
|
42
|
+
yesterday_dolar = check_cotization_for_variations("Billete", (@fecha - 1.days))
|
43
43
|
unless (today_dolar.nil? || yesterday_dolar.nil?)
|
44
44
|
porcentual_variation = ((today_dolar[:venta] - yesterday_dolar[:venta]) / (yesterday_dolar[:venta]))
|
45
45
|
porcentual_variation = "#{(porcentual_variation * 100).round(2)}%"
|
@@ -71,6 +71,21 @@ module Dolar
|
|
71
71
|
return ddolar
|
72
72
|
end
|
73
73
|
|
74
|
+
def check_cotization_for_variations dolar_type, date
|
75
|
+
query = Dolar::Bna::DolarCotization.where(date: date.to_date, dolar_type: dolar_type).first
|
76
|
+
ddolar = nil
|
77
|
+
if query.nil?
|
78
|
+
if dolar_type == "Divisa"
|
79
|
+
ddolar = get_dolar_divisa()
|
80
|
+
else
|
81
|
+
ddolar = get_dolar()
|
82
|
+
end
|
83
|
+
else
|
84
|
+
ddolar = {compra: query.dolar_buy, venta: query.dolar_sell}
|
85
|
+
end
|
86
|
+
return ddolar
|
87
|
+
end
|
88
|
+
|
74
89
|
def get_dolar
|
75
90
|
require "open-uri"
|
76
91
|
data = {}
|
data/lib/dolar/bna/version.rb
CHANGED