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"
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)


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

def initialize(ref_nbr, year = nil, opts = {})
  super ref_nbr, year

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

  @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