Skip to content

Instantly share code, notes, and snippets.

@JayK31
Created July 11, 2014 14:13
Show Gist options
  • Save JayK31/7fe10530ab184aa6d541 to your computer and use it in GitHub Desktop.
Save JayK31/7fe10530ab184aa6d541 to your computer and use it in GitHub Desktop.
def self.fetch
# fetch data from NYC openscrape
responses = HTTParty.get('http://nypd.openscrape.com/data/collisions.json.gz')
# limit the reponses to approx 700
limit_resp = responses[37000..-1]
# responses.map do |response|
limit_resp.map do |response|
traffic_incident = self.new(latitude: response[0], longitude: response[1], description: description(response))
if has_bike?(response)
traffic_incident.save
end
end
end
def self.has_bike?(response)
response[4..-1].flatten.include? 'bicycle'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment