Class: RelatonNist::HitCollection
- Inherits:
-
Array
- Object
- Array
- RelatonNist::HitCollection
- Defined in:
- lib/relaton_nist/hit_collection.rb
Overview
Page of hit collection.
Constant Summary collapse
- DOMAIN =
"https://csrc.nist.gov"
- DATAFILE =
File. "data/pubs-export.zip", __dir__
Instance Attribute Summary collapse
- #fetched ⇒ TrueClass, FalseClass readonly
- #text ⇒ String readonly
- #year ⇒ String readonly
Instance Method Summary collapse
- #fetch ⇒ Iecbib::HitCollection
-
#initialize(ref_nbr, year = nil, opts = {}) ⇒ HitCollection
constructor
A new instance of HitCollection.
- #inspect ⇒ String
- #to_s ⇒ Object
Constructor Details
#initialize(ref_nbr, year = nil, opts = {}) ⇒ HitCollection
Returns a new instance of HitCollection.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/relaton_nist/hit_collection.rb', line 30 def initialize(ref_nbr, year = nil, opts = {}) @text = ref_nbr @year = year /(?<docid>(SP|FIPS)\s[0-9-]+)/ =~ text hits = docid ? from_json(docid, **opts) : from_csrc(**opts) hits.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 concat hits @fetched = false end |
Instance Attribute Details
#fetched ⇒ TrueClass, FalseClass (readonly)
16 17 18 |
# File 'lib/relaton_nist/hit_collection.rb', line 16 def fetched @fetched end |
#text ⇒ String (readonly)
19 20 21 |
# File 'lib/relaton_nist/hit_collection.rb', line 19 def text @text end |
#year ⇒ String (readonly)
22 23 24 |
# File 'lib/relaton_nist/hit_collection.rb', line 22 def year @year end |
Instance Method Details
#fetch ⇒ Iecbib::HitCollection
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/relaton_nist/hit_collection.rb', line 50 def fetch workers = RelatonBib::WorkersPool.new 4 workers.worker(&:fetch) each do |hit| workers << hit end workers.end workers.result @fetched = true self end |
#inspect ⇒ String
67 68 69 |
# File 'lib/relaton_nist/hit_collection.rb', line 67 def inspect "<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>" end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/relaton_nist/hit_collection.rb', line 62 def to_s inspect end |