cryptocoin_fanboi 0.1.0 → 0.1.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/cryptocoin_fanboi.rb +25 -12
- metadata +1 -1
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d4c7614a3e2afc127e1987ad3d286f4a330fbbc
|
|
4
|
+
data.tar.gz: ffceccbd672c85296b3c55a3013a7016f71f29c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbe2ecd70b3098e094b00f8614ac649e2a33c53f6c7a8cc227f5f50fb0b5968dc2a0de56649b9dd4d6a7377c562e65371017781679be45efc5329fa37181e602
|
|
7
|
+
data.tar.gz: edbaa3f26338e7b5b780181eaaf2d157e38d7de3f6b5dec8f82c597472b31b6247bebebef1bbb40332368263d17c609f15e79af45b6b4414826877346c4e9198
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/cryptocoin_fanboi.rb
CHANGED
|
@@ -9,31 +9,44 @@ require 'table-formatter'
|
|
|
9
9
|
|
|
10
10
|
class CryptocoinFanboi
|
|
11
11
|
|
|
12
|
-
def initialize()
|
|
12
|
+
def initialize(watch: [])
|
|
13
13
|
|
|
14
|
+
@watch = watch.map(&:upcase)
|
|
15
|
+
|
|
14
16
|
@tfo = TableFormatter.new
|
|
15
17
|
@tfo.labels = %w(Name USD BTC) + ['% 24hr:', '% 1 week:']
|
|
18
|
+
@coins = fetch_coinlist(watch: @watch)
|
|
16
19
|
|
|
17
20
|
end
|
|
18
|
-
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
@tfo.source = fetch_coinlist limit: limit
|
|
22
|
-
@tfo.display markdown: markdown
|
|
23
|
-
|
|
21
|
+
|
|
22
|
+
def coin_abbreviations()
|
|
23
|
+
@coins.map {|x| "%s (%s)" % [x['name'], x['symbol']] }
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
alias abbreviations coin_abbreviations
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
coins = JSON.parse(Coinmarketcap.coins.body).take(limit).map do |coin|
|
|
28
|
+
def to_s(limit: nil, markdown: false)
|
|
29
|
+
|
|
30
|
+
coins = fetch_coinlist(limit: limit, watch: @watch).map do |coin|
|
|
31
31
|
|
|
32
32
|
%w(name price_usd price_btc percent_change_24h percent_change_7d)\
|
|
33
33
|
.map {|x| coin[x] }
|
|
34
34
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
@tfo.source = coins
|
|
38
|
+
@tfo.display markdown: markdown
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def fetch_coinlist(limit: nil, watch: [])
|
|
45
|
+
|
|
46
|
+
a = JSON.parse(Coinmarketcap.coins.body)
|
|
47
|
+
coins = watch.any? ? a.select {|x| watch.include? x['symbol']} : a
|
|
48
|
+
limit ? coins.take(limit) : coins
|
|
49
|
+
|
|
37
50
|
end
|
|
38
51
|
|
|
39
52
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
��/n��A
|
|
2
|
+
[i��հ�����G;�����w�v.�q5NUBȸ\�d@�D`��S:�S������?r�Q{�U>a��ʊ���s8��I���P�y��k��U3͢U��Ph��
|