Class: SbPotholes::Pothole

Inherits:
Object
  • Object
show all
Defined in:
lib/sb_potholes.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Pothole

Returns a new instance of Pothole.



8
9
10
11
12
13
14
# 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

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/sb_potholes.rb', line 6

def status
  @status
end

#street_addressObject (readonly)

Returns the value of attribute street_address.



6
7
8
# File 'lib/sb_potholes.rb', line 6

def street_address
  @street_address
end

#type_of_service_requestObject (readonly)

Returns the value of attribute type_of_service_request.



6
7
8
# File 'lib/sb_potholes.rb', line 6

def type_of_service_request
  @type_of_service_request
end

#wardObject (readonly)

Returns the value of attribute ward.



6
7
8
# File 'lib/sb_potholes.rb', line 6

def ward
  @ward
end

#zipObject (readonly)

Returns the value of attribute zip.



6
7
8
# File 'lib/sb_potholes.rb', line 6

def zip
  @zip
end

Class Method Details

.allObject



16
17
18
19
# 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

.search(search_term) ⇒ Object



21
22
23
24
# File 'lib/sb_potholes.rb', line 21

def self.search(search_term)
  potholes_array = Unirest.get("https://data.cityofchicago.org/resource/787j-mys9.json?$q=#{search_term}").body
  convert_hashes_to_objects(potholes_array)
end