module Kovid

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Constants

VERSION

Public Instance Methods

add_plus_sign(num) click to toggle source

Insert + sign to format positive numbers

# File lib/kovid/helpers.rb, line 24
def add_plus_sign(num)
  num.to_i.positive? ? "+#{comma_delimit(num)}" : comma_delimit(num).to_s
end
africa_aggregate() click to toggle source
# File lib/kovid.rb, line 19
def africa_aggregate
  Kovid::Request.africa_aggregate
end
all_us_states() click to toggle source
# File lib/kovid.rb, line 55
def all_us_states
  Kovid::Request.all_us_states
end
asia_aggregate() click to toggle source
# File lib/kovid.rb, line 27
def asia_aggregate
  Kovid::Request.asia_aggregate
end
cases() click to toggle source
# File lib/kovid.rb, line 67
def cases
  Kovid::Request.cases
end
comma_delimit(number) click to toggle source
# File lib/kovid/helpers.rb, line 19
def comma_delimit(number)
  number.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(',').reverse
end
country(name) click to toggle source
# File lib/kovid.rb, line 31
def country(name)
  Kovid::Request.by_country(name)
end
country_comparison(names_array) click to toggle source
# File lib/kovid.rb, line 59
def country_comparison(names_array)
  Kovid::Request.by_country_comparison(names_array)
end
country_comparison_full(names_array) click to toggle source
# File lib/kovid.rb, line 63
def country_comparison_full(names_array)
  Kovid::Request.by_country_comparison_full(names_array)
end
country_full(name) click to toggle source
# File lib/kovid.rb, line 35
def country_full(name)
  Kovid::Request.by_country_full(name)
end
dateman(date) click to toggle source

Parse date as “02 Apr, 20”

# File lib/kovid/helpers.rb, line 14
def dateman(date)
  date_to_parse = Date.strptime(date, '%m/%d/%y').to_s
  Date.parse(date_to_parse).strftime('%d %b, %y')
end
eu_aggregate() click to toggle source
# File lib/kovid.rb, line 11
def eu_aggregate
  Kovid::Request.eu_aggregate
end
europe_aggregate() click to toggle source
# File lib/kovid.rb, line 15
def europe_aggregate
  Kovid::Request.europe_aggregate
end
histogram(country, date) click to toggle source
# File lib/kovid.rb, line 79
def histogram(country, date)
  Kovid::Request.histogram(country, date)
end
history(country, days = 30) click to toggle source
# File lib/kovid.rb, line 71
def history(country, days = 30)
  Kovid::Request.history(country, days)
end
history_us_state(state, days = 30) click to toggle source
# File lib/kovid.rb, line 75
def history_us_state(state, days = 30)
  Kovid::Request.history_us_state(state, days)
end
info_table(message) click to toggle source
# File lib/kovid/helpers.rb, line 8
def info_table(message)
  rows = [[message.to_s]]
  puts Terminal::Table.new title: '❗️', rows: rows
end
lookup_us_state(state) click to toggle source
# File lib/kovid/helpers.rb, line 28
def lookup_us_state(state)
  us = Carmen::Country.coded('USA')
  lookup = us.subregions.coded(state) || us.subregions.named(state)
  lookup ? lookup.name : state
end
province(name) click to toggle source
# File lib/kovid.rb, line 39
def province(name)
  Kovid::Request.province(name)
end
provinces(names) click to toggle source
# File lib/kovid.rb, line 43
def provinces(names)
  Kovid::Request.provinces(names)
end
south_america_aggregate() click to toggle source
# File lib/kovid.rb, line 23
def south_america_aggregate
  Kovid::Request.south_america_aggregate
end
state(state) click to toggle source
# File lib/kovid.rb, line 47
def state(state)
  Kovid::Request.state(state)
end
states(states) click to toggle source
# File lib/kovid.rb, line 51
def states(states)
  Kovid::Request.states(states)
end
top(count, options = { location: :countries, incident: :cases }) click to toggle source
# File lib/kovid.rb, line 83
def top(count, options = { location: :countries, incident: :cases })
  Kovid::Request.top(count, options)
end