Class: Relaton::Ccsds::HitCollection
- Inherits:
-
Relaton::Core::HitCollection
- Object
- Relaton::Core::HitCollection
- Relaton::Ccsds::HitCollection
- Defined in:
- lib/relaton/ccsds/hit_collection.rb
Constant Summary collapse
- GHURL =
"https://raw.githubusercontent.com/relaton/relaton-data-ccsds/refs/heads/v2/".freeze
Instance Method Summary collapse
-
#fetch ⇒ <Type>
Search his in index.
-
#index ⇒ Object
Pubid index (index-v2): ‘:id` deserializes to a Pubid::Ccsds::Identifier via pubid_class, so search narrows by number with binary search.
- #pubid ⇒ Object
- #rows ⇒ Object
Instance Method Details
#fetch ⇒ <Type>
Search his in index.
13 14 15 16 17 18 |
# File 'lib/relaton/ccsds/hit_collection.rb', line 13 def fetch @array = rows.map { |row| Hit.new code: row[:id], url: "#{GHURL}#{row[:file]}" } self rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError, Errno::ECONNRESET => e raise Relaton::RequestError, e. end |
#index ⇒ Object
Pubid index (index-v2): ‘:id` deserializes to a Pubid::Ccsds::Identifier via pubid_class, so search narrows by number with binary search.
22 23 24 25 26 |
# File 'lib/relaton/ccsds/hit_collection.rb', line 22 def index @index ||= Relaton::Index.find_or_create( :ccsds, url: "#{GHURL}#{INDEXFILE}.zip", file: "#{INDEXFILE}.yaml", pubid_class: Pubid::Ccsds::Identifier ) end |
#pubid ⇒ Object
28 29 30 |
# File 'lib/relaton/ccsds/hit_collection.rb', line 28 def pubid @pubid ||= Pubid::Ccsds::Identifier.parse(ref) end |
#rows ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/relaton/ccsds/hit_collection.rb', line 32 def rows if pubid.edition index.search(pubid) else # search(pubid) narrows candidates by number via binary search first. index.search(pubid) { |r| r[:id].exclude(:edition) == pubid } end end |