class Kovid::CLI
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/kovid/cli.rb, line 8 def self.exit_on_failure? true end
Public Instance Methods
africa()
click to toggle source
# File lib/kovid/cli.rb, line 104 def africa puts Kovid.africa_aggregate data_source end
asia()
click to toggle source
# File lib/kovid/cli.rb, line 116 def asia puts Kovid.asia_aggregate data_source end
check(*name)
click to toggle source
# File lib/kovid/cli.rb, line 33 def check(*name) if name.size == 1 fetch_country_stats(name.pop) elsif options[:full] puts Kovid.country_comparison_full(name) else puts Kovid.country_comparison(name) end data_source end
compare(*_name)
click to toggle source
# File lib/kovid/cli.rb, line 46 def compare(*_name) Kovid.info_table("#compare is deprecated and will be removed in v7.0.0. \ \nPlease do `kovid check COUNTRY COUNTRY ...` instead.") end
eu()
click to toggle source
# File lib/kovid/cli.rb, line 92 def eu puts Kovid.eu_aggregate data_source end
europe()
click to toggle source
# File lib/kovid/cli.rb, line 98 def europe puts Kovid.europe_aggregate data_source end
histogram(country, date = nil)
click to toggle source
# File lib/kovid/cli.rb, line 127 def histogram(country, date = nil) if date.nil? Kovid.info_table("Please add a month and year in the form 'M.YY'") else puts Kovid.histogram(country, date) data_source end end
history(location, days = 30)
click to toggle source
# File lib/kovid/cli.rb, line 82 def history(location, days = 30) if options[:usa] puts Kovid.history_us_state(location, days) else puts Kovid.history(location, days) end data_source end
province(name)
click to toggle source
# File lib/kovid/cli.rb, line 16 def province(name) puts Kovid.province(name) data_source end
provinces(*names)
click to toggle source
# File lib/kovid/cli.rb, line 24 def provinces(*names) puts Kovid.provinces(names) data_source end
sa()
click to toggle source
# File lib/kovid/cli.rb, line 110 def sa puts Kovid.south_america_aggregate data_source end
state(state)
click to toggle source
# File lib/kovid/cli.rb, line 52 def state(state) puts Kovid.state(state) data_source end
states(*states)
click to toggle source
# File lib/kovid/cli.rb, line 61 def states(*states) if options[:all] puts Kovid.all_us_states else downcased_states = states.map(&:downcase) puts Kovid.states(downcased_states) end data_source end
top(count = 5)
click to toggle source
# File lib/kovid/cli.rb, line 143 def top(count = 5) count = count.to_i count = 5 if count.zero? puts Kovid.top(count, prepare_top_params(options)) data_source end
version()
click to toggle source
# File lib/kovid/cli.rb, line 122 def version puts Kovid::VERSION end
world()
click to toggle source
# File lib/kovid/cli.rb, line 73 def world puts Kovid.cases data_source end
Private Instance Methods
data_source()
click to toggle source
# File lib/kovid/cli.rb, line 160 def data_source source = <<~TEXT #{Time.now} Sources: * worldometers.info/coronavirus * Johns Hopkins University TEXT puts source end
fetch_country_stats(country)
click to toggle source
# File lib/kovid/cli.rb, line 152 def fetch_country_stats(country) if options[:full] puts Kovid.country_full(country) else puts Kovid.country(country) end end
prepare_top_params(options)
click to toggle source
# File lib/kovid/cli.rb, line 170 def prepare_top_params(options) params = { location: :countries, incident: :cases } if !options[:states].nil? && options[:countries].nil? params[:location] = :states end if !options[:deaths].nil? && options[:cases].nil? params[:incident] = :deaths end params end