Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 23, 2020 22:22
Show Gist options
  • Save havenwood/9e7f1d70ef4facb5e1a5d87162a4f606 to your computer and use it in GitHub Desktop.
Save havenwood/9e7f1d70ef4facb5e1a5d87162a4f606 to your computer and use it in GitHub Desktop.
rows = data.map do |country|
[country.values_at('country', 'cases', 'deaths', 'recovered')]
end
# then extract a constant
COUNTRY_OUTCOMES = ['country', *CASES_DEATHS_RECOVERED].freeze
rows = data.map do |country|
[country.values_at(*COUNTRY_OUTCOMES)]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment