Class: RelatonNist::HitCollection
- Inherits:
-
RelatonBib::HitCollection
- Object
- RelatonBib::HitCollection
- RelatonNist::HitCollection
- Defined in:
- lib/relaton_nist/hit_collection.rb
Overview
Hit collection.
Constant Summary collapse
- GHNISTDATA =
"https://raw.githubusercontent.com/relaton/relaton-data-nist/main/"- INDEX_FILE =
"index-v1.yaml"
Class Method Summary collapse
-
.search(text, year = nil, opts = {}) ⇒ RelatonNist::HitCollection
Create hits collection instance and search hits.
Instance Method Summary collapse
-
#initialize(text, year = nil, opts = {}) ⇒ HitCollection
constructor
A new instance of HitCollection.
-
#search ⇒ RelatonNist::HitCollection
Search nits in JSON file or GitHub repo.
-
#search_filter ⇒ Array<RelatonNist::Hit>
Filter hits by reference’s parts.
Constructor Details
#initialize(text, year = nil, opts = {}) ⇒ HitCollection
Returns a new instance of HitCollection.
21 22 23 24 |
# File 'lib/relaton_nist/hit_collection.rb', line 21 def initialize(text, year = nil, opts = {}) super text, year @opts = opts end |
Class Method Details
.search(text, year = nil, opts = {}) ⇒ RelatonNist::HitCollection
Create hits collection instance and search hits
36 37 38 |
# File 'lib/relaton_nist/hit_collection.rb', line 36 def self.search(text, year = nil, opts = {}) new(text, year, opts).search end |
Instance Method Details
#search ⇒ RelatonNist::HitCollection
Search nits in JSON file or GitHub repo
45 46 47 48 49 |
# File 'lib/relaton_nist/hit_collection.rb', line 45 def search @array = from_json @array = from_ga unless @array.any? sort_hits! end |
#search_filter ⇒ Array<RelatonNist::Hit>
Filter hits by reference’s parts
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/relaton_nist/hit_collection.rb', line 56 def search_filter # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength @array.select do |item| parts = doi_parts(item.hit[:json]) || code_parts(item.hit[:code]) (refparts[:code] && [parts[:series], item.hit[:series]].include?(refparts[:series]) && refparts[:code].casecmp(parts[:code].upcase).zero? && (refparts[:prt] == parts[:prt]) && (refparts[:vol] == parts[:vol]) && (refparts[:ver] == parts[:ver]) && (refparts[:rev] == parts[:rev]) && refparts[:draft] == parts[:draft] && refparts[:add] == parts[:add]) end end |