cryptocoin_fanboi 0.1.2 → 0.1.3

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: a6cfcf1d914116235f1fdfc3cb126ca28b6bdc3c
4
- data.tar.gz: 617fbbf5c7beb889be0a1453412ee5468a5dbec6
3
+ metadata.gz: c2ea507a04381ea847547b11a0802abbc38bc884
4
+ data.tar.gz: ad0444638682f8e4b7ef57845514d6a10cba6ab3
5
5
  SHA512:
6
- metadata.gz: b409aa36d64e58b19591a4bf896d645b427cc727723a40d3d3c58c48b6eb62cd2590b9f663ccad42fbc1dc24eaf19c404912feeedb32daaccb6c621be7735f04
7
- data.tar.gz: 499229064209a593030aff52be9d4c60366ce3734cfaf71be7034248c99240def7224193fb7c746808e05b4a7449efb0ec7cffc9f8d03c0e218d13e6a2997ca9
6
+ metadata.gz: 1d21443b5a274fb3422052bc196b321e17a81d9be728e94707ccbb36ba473d0c258d68cccdeb6bae57474fdc654041b1beab3a097aeb240bc89ad64d886ab88d
7
+ data.tar.gz: 16a1f4d539ed3f101df42f10597da4ef83ce8cc89630d010eeb0398552b8bbc70893ebf0eaf25face638fd9e03ce2afac608d654b38e76ac922ddf0c45e1704f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # file: cryptocoin_fanboi
3
+ # file: cryptocoin_fanboi.rb
4
4
 
5
5
 
6
6
  require 'coinmarketcap'
@@ -14,9 +14,11 @@ class CryptocoinFanboi
14
14
  def initialize(watch: [])
15
15
 
16
16
  @watch = watch.map(&:upcase)
17
-
18
- @tfo = TableFormatter.new
19
- @tfo.labels = %w(Name USD BTC) + ['% 1hr:', '% 24hr:', '% 1 week:']
17
+
18
+ @fields = %w(rank name price_usd price_btc percent_change_1h
19
+ percent_change_24h percent_change_7d)
20
+
21
+ @labels = %w(Rank Name USD BTC) + ['% 1hr:', '% 24hr:', '% 1 week:']
20
22
  @coins = fetch_coinlist(watch: @watch)
21
23
 
22
24
  end
@@ -27,17 +29,43 @@ class CryptocoinFanboi
27
29
 
28
30
  alias abbreviations coin_abbreviations
29
31
 
30
- def to_s(limit: nil, markdown: false)
32
+
33
+ # View the coins with the largest gains in the past hour
34
+ #
35
+ def now(limit: 5, markdown: false)
36
+
37
+ TableFormatter.new(source: top_coins('1h', limit: limit),
38
+ labels: @labels, markdown: markdown).display
39
+ end
40
+
41
+ # View the coins with the largest gains this week (past 7 days)
42
+ #
43
+ def this_week(limit: 5, markdown: false)
44
+
45
+ TableFormatter.new(source: top_coins(limit: limit),
46
+ labels: @labels, markdown: markdown).display
47
+ #top_coins(limit: limit)
48
+ end
49
+
50
+ alias week this_week
51
+
52
+ # View the coins with the largest gains today (past 24 hours)
53
+ #
54
+ def today(limit: 5, markdown: false)
55
+
56
+ TableFormatter.new(source: top_coins('24h', limit: limit),
57
+ labels: @labels, markdown: markdown).display
58
+ end
59
+
60
+ def to_s(limit: nil, markdown: false, watch: @watch)
31
61
 
32
- coins = fetch_coinlist(limit: limit, watch: @watch).map do |coin|
62
+ coins = fetch_coinlist(limit: limit, watch: watch).map do |coin|
33
63
 
34
- %w(name price_usd price_btc percent_change_1h
35
- percent_change_24h percent_change_7d).map {|x| coin[x] }
64
+ @fields.map {|x| coin[x] }
36
65
 
37
66
  end
38
67
 
39
- @tfo.source = coins
40
- @tfo.display markdown: markdown
68
+ TableFormatter.new(source: coins, labels: @labels, markdown: markdown).display
41
69
 
42
70
  end
43
71
 
@@ -50,6 +78,12 @@ class CryptocoinFanboi
50
78
  limit ? coins.take(limit) : coins
51
79
 
52
80
  end
81
+
82
+ def top_coins(period='7d', limit: 5)
83
+
84
+ @coins.sort_by {|x| -x['percent_change_' + period].to_f}.take(limit).map \
85
+ {|coin| @fields.map {|x| coin[x] }}
86
+ end
53
87
 
54
88
  end
55
89
 
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- `}\�C��R�Ѣ��$�$R��m�'��_�!�k;����q��.��EJ���z箎5�b���,1r� �t.O�[6��D]u:d]��#|�����S��G^-&�Ow�.��bA�(��Mi���4Z����͐��f���u[ G����{��!�����������,,0lN�s��3`nkHQc`�V�t J��n�X�v�an�E��<�b�|� ѱ� �`�m���C�}㉛i����2�n7��\L=Yx�?g�dW��
1
+ �QH
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  NgmsFfw10oaD3PWQ7UPxWJP14au2LUL+NGHkLrGHOMPphsZhYeXKugGO8NfcKukq
31
31
  fps=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-01-01 00:00:00.000000000 Z
33
+ date: 2018-01-02 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: coinmarketcap
metadata.gz.sig CHANGED
Binary file