Sha256: f09523a7f1e02482a9f1fcccdc76cb21f5f43be7dc193f319569eb95b4a3a7c9
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require 'typhoeus' require 'json' require_relative 'tablelize' module Kovid class Request BASE_URL = 'https://corona.lmao.ninja' class << self require 'pry' def by_country(name) path = "/countries/#{name}" fetch_url = BASE_URL + path response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body) Kovid::Tablelize.country_table(response) end def by_country_full(name) path = "/countries/#{name}" fetch_url = BASE_URL + path response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body) Kovid::Tablelize.full_country_table(response) end def by_country_comparison(list) array = [] list.each do |country| path = "/countries/#{country}" fetch_url = BASE_URL + path array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body) end Kovid::Tablelize.compare_countries_table(array) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kovid-0.1.3 | lib/kovid/request.rb |