class AustinCrime::Crime
this is the core of my scraper - json lives here
Public Class Methods
cruelty()
click to toggle source
# File lib/austin_crime/crime.rb, line 23 def self.cruelty @response = HTTParty.get(url + "'CRUELTY TO ANIMALS')&$limit=10") yeesh end
dwi()
click to toggle source
# File lib/austin_crime/crime.rb, line 13 def self.dwi @response = HTTParty.get(url + "'DWI')&$limit=10") yeesh end
harassment()
click to toggle source
# File lib/austin_crime/crime.rb, line 18 def self.harassment @response = HTTParty.get(url + "'HARASSMENT')&$limit=10") yeesh end
new()
click to toggle source
# File lib/austin_crime/crime.rb, line 5 def initialize @response = response end
theft()
click to toggle source
# File lib/austin_crime/crime.rb, line 28 def self.theft @response = HTTParty.get(url + "'THEFT')&$limit=10") yeesh end
url()
click to toggle source
# File lib/austin_crime/crime.rb, line 9 def self.url url = 'https://data.austintexas.gov/resource/rkrg-9tez.json?$where=starts_with(crime_type,' end
yeesh()
click to toggle source
# File lib/austin_crime/crime.rb, line 33 def self.yeesh puts "Got #{@response.count} results. Showing first result:" @response.first.each do |k, v| puts "#{k}: #{v}" end puts "\nEnter 'more' if you'd like to browse more entries or 'q' if you'd like Quit" input = gets.chomp if input == 'more' @response.collect do |hash| puts '--------------------' hash.collect do |k, v| # not supposed to use collect on hashes? puts "#{k}: #{v}" end.compact.reject(&:empty?) # c_cole on the assist end elsif input == 'q' puts "But you just got here! Thanks for viewing." abort else puts 'Not sure what you want. Please try again.' end end