dolar-bna 1.1.5.1 → 1.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
  SHA256:
3
- metadata.gz: 4d289d5775638dc46af66ddc62f182c189036551bfa7103fc910b904791a370c
4
- data.tar.gz: fa4d561a11b331468f216092f958b69e59f90963104cac1a3df0c540c81131a2
3
+ metadata.gz: ef54f11d440540a2e34b8b59e96b1e6dc6f700ec441bd5a8adf5514e787d4dbf
4
+ data.tar.gz: 5aae056271b79c2e27b83b397a15945914a5a5e1efe3d311408fe63a50135ffc
5
5
  SHA512:
6
- metadata.gz: 2053f50fc12c9e9a5bd5b97f3b61cf42227c816c2c9ba864bf3e0a16bcde4afafecec3af9dd25ef580921b743e6a6b010a78ae6a6e2a74546e08d0527715a31d
7
- data.tar.gz: 1b790e68287657ad1f3fb58b40d8dd85d4f71fe90009bed88bfca0032758383f09dcd0e4a7b9ca14dcea06a66b43093f0c53b1fb1db2396c4e0aa9e0bea82539
6
+ metadata.gz: a1276ce1b38116288e0b31ad8ad48c05e652818b26c87afce55b12df8903cbcc928ce12840f65d6fe489666fb71ce6330fb6f69e616503002411e8a6a9ba9938
7
+ data.tar.gz: b7027b73390e6095ab852ddc24bc6eb399a4a4f41181c5e73a36dedd8d497167e308494f76c1fc0bdd2a762697559d47b1efa7e674d6cbdefae698b7a0f43636
@@ -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)}%"
@@ -57,6 +57,21 @@ module Dolar
57
57
  private
58
58
 
59
59
  def check_cotization dolar_type, date
60
+ query = Dolar::Bna::DolarCotization.where(date: date.to_date, dolar_type: dolar_type).where("dolar_cotizations.created_at >= ?", Time.now - 1.hours).order("dolar_cotizations.created_at ASC").last
61
+ ddolar = nil
62
+ if query.nil?
63
+ if dolar_type == "Divisa"
64
+ ddolar = get_dolar_divisa()
65
+ else
66
+ ddolar = get_dolar()
67
+ end
68
+ else
69
+ ddolar = {compra: query.dolar_buy, venta: query.dolar_sell}
70
+ end
71
+ return ddolar
72
+ end
73
+
74
+ def check_cotization_for_variations dolar_type, date
60
75
  query = Dolar::Bna::DolarCotization.where(date: date.to_date, dolar_type: dolar_type).first
61
76
  ddolar = nil
62
77
  if query.nil?
@@ -1,5 +1,5 @@
1
1
  module Dolar
2
2
  module Bna
3
- VERSION = "1.1.5.1"
3
+ VERSION = "1.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolar-bna
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
- - LITECODE
7
+ - Ezequiel Lorenzo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.0.3
133
+ rubygems_version: 3.0.9
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Cotizador de USD/ARS