Class: Alternative::Fuels

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_brown) ⇒ Fuels

Returns a new instance of Fuels.



11
12
13
14
15
16
17
18
19
20
# File 'lib/chi_alternative_fuels.rb', line 11

def initialize(hash_brown)
  @id = hash_brown["id"]
  @street_address = hash_brown["street_address"]
  @status_code = hash_brown["status_code"]
  @fuel_type_code = hash_brown["fuel_type_code"]
  @city = hash_brown["city"]
  @state = hash_brown["state"]
  @date_last_confirmed = hash_brown["date_last_confirmed"]
  @owner_type_code = hash_brown["owner_type_code"]
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def city
  @city
end

#date_last_confirmedObject

Returns the value of attribute date_last_confirmed.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def date_last_confirmed
  @date_last_confirmed
end

#fuel_type_codeObject

Returns the value of attribute fuel_type_code.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def fuel_type_code
  @fuel_type_code
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def id
  @id
end

#owner_type_codeObject

Returns the value of attribute owner_type_code.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def owner_type_code
  @owner_type_code
end

#stateObject

Returns the value of attribute state.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def state
  @state
end

#status_codeObject

Returns the value of attribute status_code.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def status_code
  @status_code
end

#street_addressObject

Returns the value of attribute street_address.



9
10
11
# File 'lib/chi_alternative_fuels.rb', line 9

def street_address
  @street_address
end

Class Method Details

.allObject



22
23
24
25
26
27
# File 'lib/chi_alternative_fuels.rb', line 22

def self.all

  station_response = Unirest.get("https://data.cityofchicago.org/resource/alternative-fuel-locations.json?$limit=50").body
  convert_array_to_objects(station_response)

end

.where(search_hash) ⇒ Object



29
30
31
32
33
# File 'lib/chi_alternative_fuels.rb', line 29

def self.where(search_hash)
    search_string = convert_search_hash_to_string(search_hash)
    station_response = Unirest.get("https://data.cityofchicago.org/resource/alternative-fuel-locations.json?#{search_string}").body
    convert_array_to_objects(station_response)
end