-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.rb
More file actions
31 lines (26 loc) · 952 Bytes
/
project.rb
File metadata and controls
31 lines (26 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'open-uri'
require 'json'
require_relative 'project_view'
BASE_URL = "https://data.cityofnewyork.us/resource/uvxr-2jwn.json"
json_string_response = open(BASE_URL + "?").read
ruby_hash_response = JSON.parse(json_string_response)
def death(sex,race,ruby_hash_response)
deaths_from_2013 = ruby_hash_response.map do |d|
if d["sex"] == sex && d['race_ethnicity'] == race && d["year"] == "2013"
d
end
end
deaths_from_2013.compact.sort_by do |i|
i['death_rate'].to_f
end.reverse.each_with_index do |i, index|
if i['death_rate'] == "."
i['death_rate'] = "Unknown"
end
puts "#{index+1}. #{i["leading_cause"]}\n Death Rate: #{i["death_rate"]}\n\n"
end
gets.chomp
system "clear"
puts "\n\n\nThis data was provided free of charge by the New York City Department of Health and Mental Hygiene (DOHMH)\n\n"
puts "\n\n🌞 Have a Great Day! 🌞\n\n\n"
end
user_input(ruby_hash_response)