Module: PomberCovid19

Defined in:
lib/pomber_covid19.rb,
lib/pomber_covid19/version.rb

Defined Under Namespace

Classes: HttpRequestError, RegionNotFoundError

Constant Summary collapse

BASE_URL =
"https://pomber.github.io/covid19/timeseries.json"
VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.find_by_region_name(region_name) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
15
# File 'lib/pomber_covid19.rb', line 7

def self.find_by_region_name(region_name)
  response = HTTParty.get(BASE_URL)
  raise HttpRequestError if response.code != 200

  covid19_data = response[region_name.capitalize]
  raise RegionNotFoundError if covid19_data.nil?

  covid19_data
end