Skip to content

jaerodyne/covid19-data-ruby

Repository files navigation

Covid19Data-Ruby

Gem Version Gem semver build

A Ruby wrapper for the Coronavirus Tracker API, which by default takes data directly from the Coronavirus (nCoV) Data Repository, provided by Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE). An alternative data source can be specified and will instead pull from the U.S. County data that comes from the Conference of State Bank Supervisors. The New York Times has also been added as an additional source.

Rubygems Page

https://rubygems.org/gems/covid19_data_ruby

Installation

Add this line to your application's Gemfile:

gem 'covid19_data_ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install covid19_data_ruby

Usage

Get an array of the latest data sources, which you can later pass in as an optional named argument to all the other class methods:

Covid19Data.get_sources
=> {"sources"=>["jhu", "csbs", "nyt"]}

By default, the source for each of the following methods is set to 'jhu'. If you want to use a different source, pass it in to any method as an argument: source: 'csbs'.

Get the latest amount of total confirmed cases, deaths, and recoveries globally:

Covid19Data.get_latest
# optional source argument to use csbs
Covid19Data.get_latest(source: 'csbs')

Get case data for all locations with reported cases:

Covid19Data.get_all_locations

Find case data by country code with an optional argument to include timelines:

Covid19Data.find_by_country_code('US', with_timelines: true)

Find case data by location:

Covid19Data.find_by_location(id)

License

The gem is available as open source under the terms of the MIT License.

Changelog

View the changelog for details about the latest release.