Class: RelatonNist::HitCollection

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

Overview

Page of hit collection.

Constant Summary collapse

DOMAIN =
"https://csrc.nist.gov"
PUBS_EXPORT =
URI.join(DOMAIN, "/CSRC/media/feeds/metanorma/pubs-export")
DATAFILEDIR =
File.expand_path ".relaton/nist", Dir.home
DATAFILE =
File.expand_path "pubs-export.zip", DATAFILEDIR

Instance Method Summary collapse

Constructor Details

#initialize(ref_nbr, year = nil, opts = {}) ⇒ HitCollection

Returns a new instance of HitCollection.

Parameters:

  • ref_nbr (String)
  • year (String) (defaults to: nil)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :stage (String)


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

def initialize(ref_nbr, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize
  super ref_nbr, year

  /(?<docid>(SP|FIPS)\s[0-9-]+)/ =~ text
  @array = docid ? from_json(docid, **opts) : from_csrc(**opts)
  @array = from_csrc(**opts) unless @array.any?

  @array.sort! do |a, b|
    if a.sort_value != b.sort_value
      b.sort_value - a.sort_value
    else
      (b.hit[:release_date] - a.hit[:release_date]).to_i
    end
  end
end