10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/relaton/ogc/hit_collection.rb', line 10
def find
return self if ref.nil? || ref.empty?
row = index.search(ref).min_by { |r| r[:id] }
return self unless row
url = "#{ENDPOINT}#{row[:file]}"
resp = Faraday.get(url) { |req| req.options.timeout = 10 }
return self unless resp.status == 200
item = Item.from_yaml resp.body
item.fetched = Date.today.to_s
hit = Hit.new({ code: item.docidentifier[0]&.content, file: row[:file] }, self)
hit.instance_variable_set(:@item, item)
@array = [hit]
self
end
|