Class: SfFilmLocationApiWrapper::FilmLocation

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ FilmLocation

Returns a new instance of FilmLocation.



8
9
10
11
12
13
14
15
16
17
# File 'lib/sf_film_location_api_wrapper.rb', line 8

def initialize(hash)
  @title = hash["title"]
  @release_year = hash["release_year"]
  @locations = hash["locations"]
  @fun_facts = hash["fun_facts"]
  @production_company = hash["production_company"]
  @distributor = hash["distributor"]
  @director = hash["director"]
  @writer = hash["writer"]
end

Instance Attribute Details

#directorObject (readonly)

Returns the value of attribute director.



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

def director
  @director
end

#distributorObject (readonly)

Returns the value of attribute distributor.



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

def distributor
  @distributor
end

#fun_factsObject (readonly)

Returns the value of attribute fun_facts.



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

def fun_facts
  @fun_facts
end

#locationsObject (readonly)

Returns the value of attribute locations.



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

def locations
  @locations
end

#production_companyObject (readonly)

Returns the value of attribute production_company.



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

def production_company
  @production_company
end

#release_yearObject (readonly)

Returns the value of attribute release_year.



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

def release_year
  @release_year
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#writerObject (readonly)

Returns the value of attribute writer.



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

def writer
  @writer
end

Class Method Details

.allObject



19
20
21
22
# File 'lib/sf_film_location_api_wrapper.rb', line 19

def self.all
  array = Unirest.get("https://data.sfgov.org/resource/wwmu-gmzc.json").body
  create(array)
end

.create(array) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/sf_film_location_api_wrapper.rb', line 24

def self.create(array)
  @film_locations = []
  array.each do |hash|
    @film_locations << FilmLocation.new(hash)
  end
  return @film_locations
end

.search(string) ⇒ Object



32
33
34
35
# File 'lib/sf_film_location_api_wrapper.rb', line 32

def self.search(string)
  array = Unirest.get("https://data.sfgov.org/resource/wwmu-gmzc.json?$q=#{string}").body
  create(array)
end