class Chifoodinspect::Dataset

Attributes

results[RW]

Public Class Methods

new(ds_token='') click to toggle source
# File lib/chifoodinspect.rb, line 8
def initialize ds_token=''
  @client = SODA::Client.new({domain: 'data.cityofchicago.org', app_token: ds_token})
  @ds = "cwig-ma7x"
end

Public Instance Methods

print() click to toggle source
query(hash={}) click to toggle source
# File lib/chifoodinspect.rb, line 13
def query hash={}
  @results = @client.get(@ds, hash)
  self
end
query_local(lat, lng, radius) click to toggle source
# File lib/chifoodinspect.rb, line 18
def query_local lat, lng, radius
  hash = {"$where" => "within_circle(location, #{lat}, #{lng}, #{radius})"}
  @results = @client.get(@ds, hash)
  self
end
write_to_file(filename) click to toggle source
# File lib/chifoodinspect.rb, line 33
def write_to_file filename
  File.open(filename, "w") do |file|
    @results.each do |r|
      file.write("#{r.dba_name} || #{r.risk} || #{r.results}\n\n #{r.violations}\n\n")
    end
  end
end