Skip to content

Instantly share code, notes, and snippets.

@xcobar

xcobar/rb.rb Secret

Last active March 24, 2020 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcobar/ab04fca0c103b0dda7cd06883690f8dd to your computer and use it in GitHub Desktop.
Save xcobar/ab04fca0c103b0dda7cd06883690f8dd to your computer and use it in GitHub Desktop.
rows = []
data.each do |country|
rows << [
country['country'],
country['cases'],
country['deaths'],
country['recovered'],
check_if_positve(country['todayCases']),
check_if_positve(country['todayDeaths']),
country['critical'],
country['casesPerOneMillion']
]
end
## TOP VS BOTTOM
rows = data.map do |country|
[country.values_at('country', 'cases', 'deaths', 'recovered')].tap { |name, *| name.upcase! }
end
@havenwood
Copy link

havenwood commented Mar 24, 2020

countries.map do |country|
  [*country.values_at(*COUNTRY_STATS),
   check_if_positve(country.fetch('todayCases')),
   check_if_positve(country.fetch('todayDeaths')),
   *country.values_at('critical', 'casesPerOneMillion')]
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment