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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ebac018973d719e2fbc91b161530af5e89f0bf05b33ff38d3adbdb960fe0894
4
- data.tar.gz: d3baec3653ea8ae1f8169a7753cf717de96d6a174014d32cfe17a81a0b88d2ad
3
+ metadata.gz: 687a7d90ef5128b874b22f4a9cae467ef2e8259824f0e36a2a64f519f27a37b6
4
+ data.tar.gz: dd4c33a15f0f848193a0e741af9ac334c406e0392ddf48e8bc00b5abeaf22acc
5
5
  SHA512:
6
- metadata.gz: 64918bff0a8fb9f20e67c952079f60c808a9b085d6ffc1fba7c023940e2a6a76b39db979121e04b217329c91ff3c13a15a5d7189d4a8768856c86dfc6478e1dc
7
- data.tar.gz: 5d73d000445147844585c96ce285001d16361198c15571f5c40b01131a8c6340b88bac54b252e90073cc5f66b93a15bf5a7060bb08ff100671e93a4847d62725
6
+ metadata.gz: fbf080ba8a7e770182c8e50092775cb6e6504dc69ef2a0c05f1bfb6d4f1586631ed8a60be82be81e868c903a395c0c0362b146720629b2f107eda36a49a481c5
7
+ data.tar.gz: 41f9a8a64413d712c5d52e1fc627d9612d1458f1651ec6aed904fbb77ea798c2f0d72ab9b4df2defeefffb28cab6952164efc338ba9d8e669289ba9e06642829
@@ -38,8 +38,8 @@ module Dolar
38
38
  def variation_billete
39
39
  begin
40
40
  Timeout.timeout(15) do
41
- today_dolar = check_cotization("Billete", @fecha)
42
- yesterday_dolar = check_cotization("Billete", (@fecha - 1.days))
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 = {}
@@ -1,5 +1,5 @@
1
1
  module Dolar
2
2
  module Bna
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolar-bna
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezequiel Lorenzo