cryptocoincharts_ruby 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/cryptocoincharts_ruby.rb +11 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTA5M2U3NDg1YWFmMTRiYTYzNmNkNjgzODliYjI1MWU0Y2IyMmViYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODZjNTBjYmNjZDUyNGM0OGRmMzE4MTcyMTczNjgxMzNiOWYyOThmZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzI0YTNlMzZhYjU0N2M3ZjUzMDhhYWQ0MDc5YWNiZjAxOWFiZGNiZGU1Yzdl
|
10
|
+
NGJiOTQzNWJiZjUwNzFjMzNhNDRkYTQ2YWU4YTdlNzAxNWU5OGE1NDc0OTQ5
|
11
|
+
MDE5MzA5OWUzNmRkNDRiYTBhOTA0MGI3NjZlZTQ5NTZkZTI0M2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mzc1MjM0NjM0NzllZDU1ZDg4MWRhM2Q1MmU5NGY1MWExZTNlOWQ5ODczYWQ3
|
14
|
+
ZTg3ZGUyMWY4M2MwNGQ3ZjdjNGRlOTM0YWQzMjczNmMxNGIyNDc2ODYzOGEz
|
15
|
+
YjdhZDI5NzgzZjZjODIxYmZkZTcxZGYxMmMxNDY0ZTlkNGFiMDQ=
|
@@ -6,7 +6,7 @@ require 'bigdecimal'
|
|
6
6
|
module CryptoCoinCharts
|
7
7
|
class << self
|
8
8
|
|
9
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.15'
|
10
10
|
|
11
11
|
API_URL = 'http://www.cryptocoincharts.info/v2/api'
|
12
12
|
VALID_PAIRS = [
|
@@ -17,7 +17,7 @@ module CryptoCoinCharts
|
|
17
17
|
:btg_btc, :btq_btc, :btr_btc, :buk_btc, :c2_btc, :cach_btc, :cage_btc, :cap_btc, :cash_btc, :cat_btc,
|
18
18
|
:cdc_btc, :cent_btc, :cga_btc, :cgb_btc, :cin_btc, :clr_btc, :cmc_btc, :cnc_btc, :cnote_btc, :cny_btc,
|
19
19
|
:coin_btc, :col_btc, :con_btc, :corg_btc, :cpr_btc, :crc_btc, :csc_btc, :ctm_btc, :dbl_btc, :dem_btc,
|
20
|
-
:dgb_btc, :dgc_btc, :diem_btc, :dime_btc, :dmc_btc, :dmd_btc, :doge_btc, :drk_btc, :dsc_btc, :dtc_btc,
|
20
|
+
:dgb_btc, :dgc_btc, :diem_btc, :dime_btc, :dmc_btc, :dmd_btc, :doge_btc, :dope_btc, :drk_btc, :dsc_btc, :dtc_btc,
|
21
21
|
:duck_btc, :dvc_btc, :eac_btc, :ebt_btc, :ecc_btc, :efl_btc, :elc_btc, :elp_btc, :emc2_btc, :emd_btc,
|
22
22
|
:emo_btc, :etok_btc, :eur_btc, :exc_btc, :exe_btc, :ezc_btc, :fac_btc, :fail_btc, :ffc_btc, :flap_btc,
|
23
23
|
:flo_btc, :flt_btc, :fox_btc, :frc_btc, :fre_btc, :frk_btc, :frq_btc, :frx_btc, :fry_btc, :fsc_btc,
|
@@ -44,7 +44,8 @@ module CryptoCoinCharts
|
|
44
44
|
|
45
45
|
def list_coins
|
46
46
|
coins = JSON.parse(Mechanize.new.get("#{API_URL}/listCoins").body)
|
47
|
-
coins.map! {|c| CoinSummary.new(c) }
|
47
|
+
coins.map! {|c| CoinSummary.new(c) rescue nil }
|
48
|
+
coins.delete(nil)
|
48
49
|
coins.each do |coin|
|
49
50
|
if !VALID_PAIRS.include?("#{coin.code}_btc".to_sym)
|
50
51
|
puts "WARNING: Valid coin pair #{coin.code}_btc does not appear in the list of valid pairs!"
|
@@ -54,8 +55,9 @@ module CryptoCoinCharts
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def coin_info(pair)
|
57
|
-
raise ArgumentError, "You must supply a valid coin pair!" if !VALID_PAIRS.include?(pair.to_sym)
|
58
|
-
coins_info(pair)
|
58
|
+
#raise ArgumentError, "You must supply a valid coin pair!" if !VALID_PAIRS.include?(pair.to_sym)
|
59
|
+
coin = coins_info(pair)
|
60
|
+
!coin.nil? ? coin.first : nil
|
59
61
|
end
|
60
62
|
|
61
63
|
def coins_info(*pairs)
|
@@ -70,7 +72,9 @@ module CryptoCoinCharts
|
|
70
72
|
coins = JSON.parse(Mechanize.new.post("#{API_URL}/tradingPairs", {
|
71
73
|
:pairs => pairs.join(',')
|
72
74
|
}).body)
|
73
|
-
coins.map {|c| CoinDetail.new(c) }
|
75
|
+
coins.map! {|c| CoinDetail.new(c) rescue nil }
|
76
|
+
coins.delete(nil)
|
77
|
+
coins
|
74
78
|
end
|
75
79
|
|
76
80
|
end
|
@@ -86,7 +90,7 @@ module CryptoCoinCharts
|
|
86
90
|
class CoinDetail < Hashie::Trash
|
87
91
|
property :code, :from => :id, :with => lambda {|v| v.gsub!(/\//, '_').to_sym }
|
88
92
|
property :best_market
|
89
|
-
property :latest_trade, :transform_with => lambda {|v| Time.parse(v) }
|
93
|
+
property :latest_trade, :transform_with => lambda {|v| Time.parse(v) rescue v }
|
90
94
|
property :btc_value, :from => :price, :with => lambda {|v| BigDecimal.new(v) }
|
91
95
|
property :btc_value_24h_ago, :from => :price_before_24h, :with => lambda {|v| BigDecimal.new(v) }
|
92
96
|
property :btc_volume, :from => :volume_btc, :with => lambda {|v| v.to_f }
|