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:, logger: GeoCombine::Logger.logger) ⇒ LegacyBlacklightResponse
constructor
A new instance of LegacyBlacklightResponse.
Constructor Details
#initialize(response:, base_url:, logger: GeoCombine::Logger.logger) ⇒ LegacyBlacklightResponse
Returns a new instance of LegacyBlacklightResponse.
97 98 99 100 101 102 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 97 def initialize(response:, base_url:, logger: GeoCombine::Logger.logger) @base_url = base_url @response = response @page = 1 @logger = logger end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
94 95 96 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 94 def base_url @base_url end |
#page ⇒ Object
Returns the value of attribute page.
95 96 97 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 95 def page @page end |
#response ⇒ Object
Returns the value of attribute response.
95 96 97 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 95 def response @response end |
Instance Method Details
#documents ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/geo_combine/geo_blacklight_harvester.rb', line 104 def documents return enum_for(:documents) unless block_given? while current_page && total_pages && (current_page <= total_pages) yield response.dig('response', 'docs') break if current_page == total_pages self.page += 1 @logger.debug "fetching page #{page} @ #{url}" begin self.response = JSON.parse(Net::HTTP.get(URI(url))) rescue StandardError => e @logger.error "request for #{url} failed with #{e}" self.response = nil end end end |