class PigSniffer::Police

Attributes

address[R]
city[R]
district[R]
location[R]
state[R]
zip[R]

Public Class Methods

all() click to toggle source
# File lib/pig_sniffer.rb, line 20
def self.all
  api_array = Unirest.get('https://data.cityofchicago.org/resource/z8bn-74gv.json').body
  police_stations = []
  api_array.each do |station|
    police_stations << Police.new(station)
  end
  police_stations
end
new(police_api_info) click to toggle source
# File lib/pig_sniffer.rb, line 10
def initialize(police_api_info)
  @zip = police_api_info["zip"]
  @location = police_api_info["location"]
  @address = police_api_info["address"]
  @state = police_api_info["state"]
  @district = police_api_info["district"]
  @city = police_api_info["city"]
end
search_address(search_address) click to toggle source
# File lib/pig_sniffer.rb, line 29
def self.search_address(search_address)
  api_array = Unirest.get("https://data.cityofchicago.org/resource/z8bn-74gv.json?address=#{search_address}").body
  police_stations = []

  police_stations = []
  
  api_array.each do |station|
    police_stations << Police.new(station)
  end
  police_stations
end