Skip to content

Instantly share code, notes, and snippets.

@funzoneq
Created November 6, 2016 10:50
Show Gist options
  • Save funzoneq/37252bf4b0e1e1b9cd6018f973d528ad to your computer and use it in GitHub Desktop.
Save funzoneq/37252bf4b0e1e1b9cd6018f973d528ad to your computer and use it in GitHub Desktop.
require 'httparty'
def print_traffic_nl(road_name, road_type, total_length)
puts "nl_traffic_jam_kilometers{road_type=\"#{road_type}\",road_name=\"#{road_name}\"} #{total_length}"
end
response = HTTParty.get('http://api.routeradar.nl/api/v1/reports?query_type=overview')
response.parsed_response.each do |tra|
next if tra['type'] != 'jam'
print_traffic_nl(tra['road_location']['road_name'], tra['road_location']['road_type'], tra['total_length'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment