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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 347752be962e97bf3e8a9c1f6558b24810d4f2fe
4
- data.tar.gz: 270035196f146b30538d6df4d6bf06c01b632599
3
+ metadata.gz: 4d4c7614a3e2afc127e1987ad3d286f4a330fbbc
4
+ data.tar.gz: ffceccbd672c85296b3c55a3013a7016f71f29c0
5
5
  SHA512:
6
- metadata.gz: 5bf16fcdf1eee6d5fc2223e9c9502c8514eefe2d2fabab90c7ba79be43630997c625d8936361cfe495205cdcf54c636ac493ad19bd2c6109852fbd1b3040e495
7
- data.tar.gz: 74ea125d94994c89c5702baae9ed6e74e2361455a8d9aa68cec87c1f27dc885b09433f99e06c18d01ee1edb072dad454093cae960cf43abb4094aa83d899ac7b
6
+ metadata.gz: dbe2ecd70b3098e094b00f8614ac649e2a33c53f6c7a8cc227f5f50fb0b5968dc2a0de56649b9dd4d6a7377c562e65371017781679be45efc5329fa37181e602
7
+ data.tar.gz: edbaa3f26338e7b5b780181eaaf2d157e38d7de3f6b5dec8f82c597472b31b6247bebebef1bbb40332368263d17c609f15e79af45b6b4414826877346c4e9198
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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 to_s(limit: 5, markdown: false)
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
- private
27
-
28
- def fetch_coinlist(limit: 5)
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptocoin_fanboi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
-
2
- bAO-V��W�|�<����T-��2uTl|Y妉<`K�dhb���@��"�r&���
1
+ ��/n��A
2
+ [i��հ�����G;�����wv.�q5NUBȸ\�d@�D`��S:�S������?r�Q{�U>a��ʊ���s8��I���P�y��k��U3͢U��Ph��