Class: ChicagoLibraries::Library

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(library_info) ⇒ Library

Returns a new instance of Library.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/chicago_libraries.rb', line 10

def initialize(library_info)
  @zip_code = library_info["zip"],
  @phone = library_info["phone"],
  @teacher_in_library = library_info["teacher_in_the_library"],
  @longitude = library_info["location"]["longitude"],
  @latitude = library_info["location"]["latitude"],
  @website = library_info["website"]["url"],
  @address = library_info["address"],
  @hours = library_info["hours_of_operation"],
  @state = library_info["state"],
  @cybernavigator = library_info["cybernavigator"],
  @name = library_info["name_"],
  @city = library_info["city"]
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def address
  @address
end

#cityObject

Returns the value of attribute city.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def city
  @city
end

#cybernavigatorObject

Returns the value of attribute cybernavigator.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def cybernavigator
  @cybernavigator
end

#hoursObject

Returns the value of attribute hours.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def hours
  @hours
end

#latitudeObject

Returns the value of attribute latitude.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def longitude
  @longitude
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def phone
  @phone
end

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def state
  @state
end

#teacher_in_libraryObject

Returns the value of attribute teacher_in_library.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def teacher_in_library
  @teacher_in_library
end

#websiteObject

Returns the value of attribute website.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def website
  @website
end

#zip_codeObject

Returns the value of attribute zip_code.



8
9
10
# File 'lib/chicago_libraries.rb', line 8

def zip_code
  @zip_code
end

Class Method Details

.allObject



25
26
27
28
# File 'lib/chicago_libraries.rb', line 25

def self.all
  api_array = Unirest.get("https://data.cityofchicago.org/resource/x8fc-8rcq.json").body
  create_libraries(api_array)
end

.search(search_keyword) ⇒ Object



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

def self.search(search_keyword)
  api_array = Unirest.get("https://data.cityofchicago.org/resource/x8fc-8rcq.json?$q=#{search_keyword}").body
  create_libraries(api_array)
end