Class: Capwatch::List
- Inherits:
-
Object
- Object
- Capwatch::List
- Defined in:
- lib/capwatch/list.rb
Class Method Summary collapse
Class Method Details
.format(response, limit: 50) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/capwatch/list.rb', line 6 def self.format(response, limit: 50) response.first(limit).map do |coin| [ coin["name"], Console::Formatter.format_usd(coin["price_usd"]), Console::Formatter.condition_color(Console::Formatter.format_percent(coin["percent_change_24h"])), Console::Formatter.condition_color(Console::Formatter.format_percent(coin["percent_change_7d"])) ] end end |
.watch ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/capwatch/list.rb', line 17 def self.watch response = Providers::CoinMarketCap.new.fetched_json body = format(response) table = Terminal::Table.new do |t| t.style = { # border_top: false, border_bottom: false, border_y: "", border_i: "", padding_left: 1, padding_right: 1 } t.headings = [ "SYMBOL", "PRICE", "24H %", "7D %" ] body.each { |x| t << x } end table end |