Class: RelatonOgc::HitCollection

Inherits:
RelatonBib::HitCollection
  • Object
show all
Defined in:
lib/relaton_ogc/hit_collection.rb

Constant Summary collapse

ENDPOINT =

ENDPOINT = “raw.githubusercontent.com/opengeospatial/”\

"NamingAuthority/master/incubation/bibliography/"\
"bibliography.json".freeze
"https://raw.githubusercontent.com/relaton/relaton-data-ogc/main/data/".freeze

Instance Method Summary collapse

Constructor Details

#initialize(code, year = nil) ⇒ HitCollection



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/relaton_ogc/hit_collection.rb', line 20

def initialize(code, year = nil)
  super
  # @etagfile = File.expand_path "etag.txt", DATADIR
  # @array = from_json(ref).sort_by do |hit|
  #   hit.hit["date"] ? Date.parse(hit.hit["date"]) : Date.new
  # rescue ArgumentError
  #   Date.parse "0000-01-01"
  # end.reverse
  resp = Faraday.get "#{ENDPOINT}#{code.upcase.gsub(/[\s:.]/, '_')}.yaml"
  @array = case resp.status
           when 200
             bib = OgcBibliographicItem.from_hash YAML.safe_load(resp.body)
             [Hit.new(bib, self)]
           else []
           end
end