cryptoexchange 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66f0b0109d6f99f30b5812d0f857345cfaaa853b
4
- data.tar.gz: e0c3d4816e13d575eebc8acb5c69fde29edbadbc
3
+ metadata.gz: 62e21ac1114453a0d2142de290427e10c71fc935
4
+ data.tar.gz: ed76b62159b3f148729d82215e43a25030dfccaf
5
5
  SHA512:
6
- metadata.gz: 39c658176740743e24702d75a0c864713de87e9c47895a3c9b8051e437ebd8779fddfc2e1ff321b7bae5b4971944d56541778ff75f6873eff7d65ca2b3af6b1e
7
- data.tar.gz: 9fcd45a098ff706af57885d065dc9b19d5b0ed0078743d011446be5b91883585f6ac628dcee68d2fbf0fd28433c7c2b680cfbdc0ed2bda564bad0bd8d8eaae2c
6
+ metadata.gz: df9d2780eea6f9d38834f2420c169477617fb682c4384fc1399430305c6b8da71572b9fe816c3c4ecebe7f94ad09233abe0523d183831e5ee48c4f0bd91a15db
7
+ data.tar.gz: 5eb9253ac3265b7c101194a6b9e1e2d372c16126430d110fdab43e393ebdd15ac850432d92d13fe202bdab4a069151355a330c364da07bacc9b422bf4304370b
@@ -41,7 +41,7 @@ module Cryptoexchange::Exchanges
41
41
  ticker.ask = NumericHelper.to_d(market['AskPrice'])
42
42
  ticker.high = NumericHelper.to_d(market['HighPrice'])
43
43
  ticker.low = NumericHelper.to_d(market['LowPrice'])
44
- ticker.volume = NumericHelper.to_d(market['Volume'])/ticker.last
44
+ ticker.volume = NumericHelper.divide(NumericHelper.to_d(market['Volume']), ticker.last)
45
45
  ticker.timestamp = Time.now.to_i
46
46
  ticker.payload = market
47
47
  ticker
@@ -33,7 +33,7 @@ module Cryptoexchange::Exchanges
33
33
  ticker.ask = NumericHelper.to_d(market['ask'])
34
34
  ticker.high = NumericHelper.to_d(market['high24h'])
35
35
  ticker.low = NumericHelper.to_d(market['low24h'])
36
- ticker.volume = NumericHelper.to_d(market['volume24h']) / ticker.last
36
+ ticker.volume = NumericHelper.divide(NumericHelper.to_d(market['volume24h']), ticker.last)
37
37
  ticker.timestamp = Time.now.to_i
38
38
  ticker.payload = market
39
39
  ticker
@@ -3,5 +3,10 @@ class NumericHelper
3
3
  def to_d(number)
4
4
  number ? BigDecimal.new(number.to_s) : nil
5
5
  end
6
+
7
+ def divide(number, divisor)
8
+ result = number / divisor
9
+ result.nan? || result.infinite? ? 0 : result
10
+ end
6
11
  end
7
12
  end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptoexchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - TM Lee