Sha256: 799a92ecc62b4047a826b3e865f6cfd4f760df715e6351e54a977485566a0755
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true require 'terminal-table' module Kovid class Tablelize class << self def country_table(data) headings = %w[Cases Deaths Recovered] rows = [] rows << [data['cases'], data['deaths'], data['recovered']] puts Terminal::Table.new(title: data['country'], headings: headings, rows: rows) end def full_country_table(data) headings = [ 'Cases', 'Deaths', 'Recovered', 'Cases Today', 'Deaths Today', 'Critical', 'Cases/Million' ] rows = [] rows << [ data['cases'], data['deaths'], data['recovered'], data['todayCases'], data['todayDeaths'], data['critical'], data['casesPerOneMillion'] ] puts Terminal::Table.new(title: data['country'], headings: headings, rows: rows) end def compare_countries_table(data) headings = %w[Country Cases Deaths Recovered] rows = [] data.each do |country| rows << [country['country'], country['cases'], country['deaths'], country['recovered']] end puts Terminal::Table.new(headings: headings, rows: rows) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kovid-0.1.3 | lib/kovid/tablelize.rb |