class NycTheaters::Theater
Attributes
address[R]
city[R]
name[R]
phone[R]
url[R]
zip[R]
Public Class Methods
all()
click to toggle source
# File lib/nyc_theaters.rb, line 18 def self.all theaters_array = Unirest.get('https://data.cityofnewyork.us/resource/2hzz-95k8.json').body create_theaters(theaters_array) end
create_theaters(theaters_array)
click to toggle source
# File lib/nyc_theaters.rb, line 37 def self.create_theaters(theaters_array) theaters = [] theaters_array.each do |theater| theaters << theater end end
find_by(search_term)
click to toggle source
# File lib/nyc_theaters.rb, line 30 def self.find_by(search_term) key = search_term.keys.first.to_s value = search_term.values.first theater = Unirest.get("https://data.cityofnewyork.us/resource/2hzz-95k8.json?#{key}=#{value}").body.first Theater.new(theater) end
new(theater)
click to toggle source
# File lib/nyc_theaters.rb, line 9 def initialize(theater) @name = theater['name'], @url = theater['url'], @phone = theater['tel'], @address = theater['address1'], @city = theater['city'], @zip = theater['zip'] end
where(search_term)
click to toggle source
# File lib/nyc_theaters.rb, line 23 def self.where(search_term) key = search_term.keys.first.to_s value = search_term.values.first theaters_array = Unirest.get("https://data.cityofnewyork.us/resource/2hzz-95k8.json?#{key}=#{value}").body create_theaters(theaters_array) end