class NycFireHouses::FireHouse

Attributes

borough[R]
facilityaddress[R]
facilityname[R]

Public Class Methods

all() click to toggle source
# File lib/nyc_fire_houses.rb, line 15
def self.all
    fire_house_array = Unirest.get('https://data.cityofnewyork.us/resource/byk8-bdfw.json').body
    create_fire_houses(fire_house_array)
end
new(fire_house) click to toggle source
# File lib/nyc_fire_houses.rb, line 9
def initialize(fire_house)
  @borough = fire_house["borough"]
  @name = fire_house["facilityname"]
  @addrress = fire_house["facilityaddress"]
end
where(fire_house) click to toggle source
# File lib/nyc_fire_houses.rb, line 20
def self.where(fire_house)
   key = fire_house.keys.first.to_s
   value = fire_house.values.first
   fire_house_array = Unirest.get("https://data.cityofnewyork.us/resource/byk8-bdfw.json?#{key}=#{value}").body
   create_fire_houses(fire_house_array)
end

Private Class Methods

create_fire_houses(fire_house_array) click to toggle source
# File lib/nyc_fire_houses.rb, line 27
def self.create_fire_houses(fire_house_array)
  fire_house_array.map { |fire_house| FireHouse.new(fire_house)}
end