currency_quote 0.2.1 → 0.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: 403e17ea3aacaa228865ab8672a3187971105d9e9ca988ba872151078564896f
4
- data.tar.gz: d8d0b773152e7fffe3013a56f70def54d2d3d6d2eb8959d3d1e07da73a91e5bf
3
+ metadata.gz: 497ba47e3157da48f395e426c66c2a08f1f1fc383d5de2ec45b9c677b33d4b78
4
+ data.tar.gz: 59f706e2f84045c6544df5f657a434d22c1408098737ddb805db2731475acd47
5
5
  SHA512:
6
- metadata.gz: 65ac6aa4c42c94321596240aacb69015e4e4f469c0e1246ef6f8fc342e256d2e6f63bc884fc4422aa3cf678b65f345e4d690bbae75c5fe460fb460ca3cdfbcce
7
- data.tar.gz: 7a66cada67f6c9ae1369d8870afc650dc298b095a97efc349ebbc01b0c365138e8e402442b347afa9b72903b667119e3749a0ff1c8920ef669fa652fdfebd915
6
+ metadata.gz: 65f36c0830126a87310b1e2dee724b12fbb5cd4e6b1d4350762570e66cc97a285586d08396827a8658a5bf604717f1efe1c7c4f29416aafb729266681e103f85
7
+ data.tar.gz: 585b42b3b3b6ff2a3dcaeb307e52148494e2a45a5d3ead721a63e45cb5f9328ad003093feecba23c31ee65fc2152a19d8d15265d1b025342e4f7bf6cdb5d3570
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- currency_quote (0.2.0)
4
+ currency_quote (0.2.1)
5
5
  addressable
6
6
  nokogiri
7
7
 
@@ -15,10 +15,13 @@ class CurrencyQuote::Currency
15
15
 
16
16
  def get_quotation
17
17
  if currency == "Dolar Estadounidense"
18
- get_dolar_quotation
19
- get_dolar_quotation
20
- make_get_to_bcra
21
- get_currency_quotation
18
+ begin
19
+ get_dolar_quotation
20
+ make_get_to_bcra
21
+ get_currency_quotation
22
+ rescue Timeout::Error => e
23
+ @sell = @buy = @quote = 0
24
+ end
22
25
  return struct
23
26
  end
24
27
  end
@@ -44,7 +47,7 @@ class CurrencyQuote::Currency
44
47
  @sell = (dolar.sell * pass).to_f
45
48
  @buy = (dolar.buy * pass).to_f
46
49
  else
47
- @sell = @buy = 0
50
+ @sell = @buy = @quote = 0
48
51
  end
49
52
  end
50
53
 
@@ -13,8 +13,12 @@ class CurrencyQuote::Dolar
13
13
  end
14
14
 
15
15
  def get_quotation
16
- make_get_to_bna
17
- extract_data
16
+ begin
17
+ make_get_to_bna
18
+ extract_data
19
+ rescue Timeout::Error => e
20
+ @data = @sell = @buy = 0
21
+ end
18
22
  return struct
19
23
  end
20
24
 
@@ -35,9 +39,13 @@ class CurrencyQuote::Dolar
35
39
 
36
40
  def extract_data
37
41
  data = @doc.css("td").map(&:text)
38
- @date = data[data.size - 1]
39
- @sell = data[data.size - 2].gsub(",", ".").to_f
40
- @buy = data[data.size - 3].gsub(",", ".").to_f
42
+ if data.empty?
43
+ @data = @sell = @buy = 0
44
+ else
45
+ @date = data[data.size - 1]
46
+ @sell = data[data.size - 2].gsub(",", ".").to_f
47
+ @buy = data[data.size - 3].gsub(",", ".").to_f
48
+ end
41
49
  end
42
50
 
43
51
  def struct
@@ -1,3 +1,3 @@
1
1
  module CurrencyQuote
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currency_quote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Facundo A. Díaz Martínez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-17 00:00:00.000000000 Z
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri