Class: GeoCombine::GeoBlacklightHarvester::LegacyBlacklightResponse
- Inherits:
-
Object
- Object
- GeoCombine::GeoBlacklightHarvester::LegacyBlacklightResponse
- Defined in:
- lib/geo_combine/geo_blacklight_harvester.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#page ⇒ Object
Returns the value of attribute page.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #documents ⇒ Object
-
#initialize(response:, base_url:) ⇒ LegacyBlacklightResponse
constructor
A new instance of LegacyBlacklightResponse.
Constructor Details
#initialize(response:, base_url:) ⇒ LegacyBlacklightResponse
Returns a new instance of LegacyBlacklightResponse.
88 89 90 91 92 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 88 def initialize(response:, base_url:) @base_url = base_url @response = response @page = 1 end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
86 87 88 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 86 def base_url @base_url end |
#page ⇒ Object
Returns the value of attribute page.
87 88 89 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 87 def page @page end |
#response ⇒ Object
Returns the value of attribute response.
87 88 89 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 87 def response @response end |
Instance Method Details
#documents ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 94 def documents return enum_for(:documents) unless block_given? while current_page && total_pages && (current_page <= total_pages) do yield response.dig('response', 'docs') break if current_page == total_pages self.page += 1 puts "Fetching page #{page} @ #{url}" if GeoCombine::GeoBlacklightHarvester.config[:debug] begin self.response = JSON.parse(Net::HTTP.get(URI(url))) rescue => e puts "Request for #{url} failed with #{e}" self.response = nil end end end |