coinmarketcap 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 749fa1060c381246b4b43101cae139c04cb23e1e
4
- data.tar.gz: cb81692724372c3f0a5c9731615a9015b9ac96dd
3
+ metadata.gz: 62cefa3f1ddfe4a8c142dcf9dbfd6337140fcb16
4
+ data.tar.gz: 63f977f36f55db8cef16fa043bb88a77f0a0e1ba
5
5
  SHA512:
6
- metadata.gz: 45f60a42061ce0ef9275a805d9024e513447e7e06439229b0d5d1a7f3e260df304b634fe62514411454144a87ccc3e76db94485cf2c35f82f841da429557d85a
7
- data.tar.gz: 30625feb3c0851d1c8b03e24d6f2b15a25a0365ca0dd9255a37acb1c354a69318815cdfdfcac6f99352eb4d16562c81678207da92b372441f789c0726c940214
6
+ metadata.gz: 7638e027668a14a0ac3863f2b362db9827772999986630047f37237e36c14bab32c83edb52a03baddbf6c28096179c06682f8454eb74f53f283ee06718ae755d
7
+ data.tar.gz: ada461209b89108fcf0558e93fb8f54c47aee4331add639827111621d2ff656adcf8f6463a15a5f237050fb88dce74ce8898ab13bcf85c3e38abff8c9c46f835
@@ -25,22 +25,24 @@ module Coinmarketcap
25
25
  prices = []
26
26
  doc = Nokogiri::HTML(open("https://coinmarketcap.com/currencies/#{id}/historical-data/?start=#{start_date}&end=#{end_date}"))
27
27
  rows = doc.css('tr')
28
- if rows.count == 31 || rows.count == 2
28
+ if rows.count == 31
29
29
  doc = Nokogiri::HTML(open("https://coinmarketcap.com/assets/#{id}/historical-data/?start=#{start_date}&end=#{end_date}"))
30
30
  rows = doc.css('tr')
31
31
  end
32
32
  rows.shift
33
33
  rows.each do |row|
34
34
  begin
35
- price_bundle = {}
36
35
  each_row = Nokogiri::HTML(row.to_s).css('td')
37
- price_bundle[:date] = Date.parse(each_row[0].text)
38
- price_bundle[:open] = each_row[1].text.to_f
39
- price_bundle[:high] = each_row[2].text.to_f
40
- price_bundle[:low] = each_row[3].text.to_f
41
- price_bundle[:close] = each_row[4].text.to_f
42
- price_bundle[:avg] = ( price_bundle[:high] + price_bundle[:low] ) / 2.0
43
- prices << price_bundle
36
+ if each_row.count > 1
37
+ price_bundle = {}
38
+ price_bundle[:date] = Date.parse(each_row[0].text)
39
+ price_bundle[:open] = each_row[1].text.to_f
40
+ price_bundle[:high] = each_row[2].text.to_f
41
+ price_bundle[:low] = each_row[3].text.to_f
42
+ price_bundle[:close] = each_row[4].text.to_f
43
+ price_bundle[:avg] = ( price_bundle[:high] + price_bundle[:low] ) / 2.0
44
+ prices << price_bundle
45
+ end
44
46
  rescue => error
45
47
  next
46
48
  end
@@ -1,3 +1,3 @@
1
1
  module Coinmarketcap
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinmarketcap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankit Samarthya