Created
July 11, 2014 14:13
-
-
Save JayK31/7fe10530ab184aa6d541 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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