class SbPotholes::Pothole

Attributes

status[R]
street_address[R]
type_of_service_request[R]
ward[R]
zip[R]

Public Class Methods

all() click to toggle source
# File lib/sb_potholes.rb, line 16
def self.all
  potholes_array = Unirest.get("https://data.cityofchicago.org/resource/787j-mys9.json").body
  convert_hashes_to_objects(potholes_array)
end
new(hash) click to toggle source
# File lib/sb_potholes.rb, line 8
def initialize(hash)
  @status = hash["status"]
  @street_address = hash["street_address"]
  @type_of_service_request = hash["type_of_service_request"]
  @ward = hash["ward"]
  @zip = hash["zip"]
end

Private Class Methods

convert_hashes_to_objects(array_of_hashes) click to toggle source
# File lib/sb_potholes.rb, line 28
def self.convert_hashes_to_objects(array_of_hashes)
  potholes = []
  array_of_hashes.each do |pothole_hash|
    potholes << Pothole.new(pothole_hash)
  end
  potholes
end