currency_quote 0.1.2 → 0.1.7
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.rb +0 -3
- data/lib/currency_quote/currency.rb +16 -8
- data/lib/currency_quote/dolar.rb +6 -5
- data/lib/currency_quote/version.rb +1 -1
- metadata +2 -5
- data/lib/support/hash.rb +0 -12
- data/lib/support/string.rb +0 -8
- data/lib/support/symbol.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5b18309249ed756d407c332b6b2f9d94f9f1f66b00ee3de1fda96b812da3853
|
4
|
+
data.tar.gz: 2b770235571cdd10fcad5f1d78ed4f0a71bd94e6c43749a7ef68fad466138db9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d62e4e79f1e5eff18b3abe03e8c520ed935721d8c0d9e5a908bf8a10ae091474dc0aa6cc7dd79da6ebf42c9b8b7e73d845fe9c465b78900859d39ed5393127a
|
7
|
+
data.tar.gz: c7c5e006a97dc8cad4dde90b78a3856b6e38dc31ac717735576fc2b42444de78d42426f96f7d5e9e2856dc08bf74999b09535bf37c3a8ec223e78eb309cb7977
|
data/Gemfile.lock
CHANGED
data/lib/currency_quote.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require_relative "currency_quote/version"
|
2
2
|
require_relative "currency_quote/dolar"
|
3
3
|
require_relative "currency_quote/currency"
|
4
|
-
require_relative "support/hash.rb"
|
5
|
-
require_relative "support/string.rb"
|
6
|
-
require_relative "support/symbol.rb"
|
7
4
|
|
8
5
|
module CurrencyQuote
|
9
6
|
class Error < StandardError; end
|
@@ -14,10 +14,14 @@ class CurrencyQuote::Currency
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_quotation
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
if currency == "Dolar Estadounidense"
|
18
|
+
return get_dolar_quotation
|
19
|
+
else
|
20
|
+
get_dolar_quotation
|
21
|
+
make_get_to_bcra
|
22
|
+
get_currency_quotation
|
23
|
+
return struct
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
private
|
@@ -34,10 +38,14 @@ class CurrencyQuote::Currency
|
|
34
38
|
def get_currency_quotation
|
35
39
|
data = @doc.css("td").map(&:text).collect(&:strip!)
|
36
40
|
index = data.index(currency)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
if index
|
42
|
+
quote = data[index + 1].gsub(",", ".").to_f
|
43
|
+
quote = 1.0 if quote == 0
|
44
|
+
@sell = (dolar.sell * quote).to_f
|
45
|
+
@buy = (dolar.buy * quote).to_f
|
46
|
+
else
|
47
|
+
@sell = @buy = 0
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
def struct
|
data/lib/currency_quote/dolar.rb
CHANGED
@@ -2,6 +2,7 @@ class CurrencyQuote::Dolar
|
|
2
2
|
require 'open-uri'
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'date'
|
5
|
+
require "addressable/uri"
|
5
6
|
|
6
7
|
attr_accessor :date, :doc, :sell, :buy
|
7
8
|
|
@@ -20,14 +21,14 @@ class CurrencyQuote::Dolar
|
|
20
21
|
private
|
21
22
|
|
22
23
|
def make_get_to_bna
|
23
|
-
|
24
|
-
|
24
|
+
params = Addressable::URI.new
|
25
|
+
params.query_values = {
|
25
26
|
id: 'billetes',
|
26
27
|
fecha: date,
|
27
28
|
filtroEuro: 0,
|
28
29
|
filtroDolar: 1
|
29
30
|
}
|
30
|
-
url = "#{BASE_URL}?#{
|
31
|
+
url = "#{BASE_URL}?#{params.query}"
|
31
32
|
|
32
33
|
@doc = Nokogiri::HTML( URI.open(url) )
|
33
34
|
end
|
@@ -35,8 +36,8 @@ class CurrencyQuote::Dolar
|
|
35
36
|
def extract_data
|
36
37
|
data = @doc.css("td").map(&:text)
|
37
38
|
@date = data[data.size - 1]
|
38
|
-
@sell = data[data.size - 2].to_f
|
39
|
-
@buy = data[data.size - 3].to_f
|
39
|
+
@sell = data[data.size - 2].gsub(",", ".").to_f
|
40
|
+
@buy = data[data.size - 3].gsub(",", ".").to_f
|
40
41
|
end
|
41
42
|
|
42
43
|
def struct
|
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.1.
|
4
|
+
version: 0.1.7
|
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-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -34,9 +34,6 @@ files:
|
|
34
34
|
- lib/currency_quote/currency.rb
|
35
35
|
- lib/currency_quote/dolar.rb
|
36
36
|
- lib/currency_quote/version.rb
|
37
|
-
- lib/support/hash.rb
|
38
|
-
- lib/support/string.rb
|
39
|
-
- lib/support/symbol.rb
|
40
37
|
homepage: https://www.sesocio.com
|
41
38
|
licenses:
|
42
39
|
- MIT
|
data/lib/support/hash.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
|
3
|
-
def to_query(namespace = nil)
|
4
|
-
query = collect do |key, value|
|
5
|
-
value.to_s.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
6
|
-
end.compact
|
7
|
-
|
8
|
-
query.sort! unless namespace.to_s.include?("[]")
|
9
|
-
query.join("&")
|
10
|
-
end
|
11
|
-
alias_method :to_param, :to_query
|
12
|
-
end
|
data/lib/support/string.rb
DELETED