Sha256: 5107d0fa603fcf9a3a7b1dd4ef85df8d59d097fef56aab0c401936821a0e2e2d
Contents?: true
Size: 1010 Bytes
Versions: 1
Compression:
Stored size: 1010 Bytes
Contents
# frozen_string_literal: true module Capwatch class List 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capwatch-0.2.5 | lib/capwatch/list.rb |