Class: Relaton::Ccsds::HitCollection

Inherits:
Relaton::Core::HitCollection
  • Object
show all
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

Instance Method Details

#fetch<Type>

Search his in index.

Returns:

  • (<Type>)

    <description>



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.message
end

#indexObject



20
21
22
23
24
# File 'lib/relaton/ccsds/hit_collection.rb', line 20

def index
  @index ||= Relaton::Index.find_or_create(
    :ccsds, url: "#{GHURL}#{INDEXFILE}.zip", file: "#{INDEXFILE}.yaml", pubid_class: Pubid::Ccsds::Identifier
  )
end

#pubidObject



26
27
28
# File 'lib/relaton/ccsds/hit_collection.rb', line 26

def pubid
  @pubid ||= Pubid::Ccsds::Identifier.parse(ref)
end

#rowsObject



30
31
32
33
34
35
36
37
# File 'lib/relaton/ccsds/hit_collection.rb', line 30

def rows
  if pubid.edition
    index.search(pubid)
    # index.search { |r| Pubid::Ccsds::Identifier.create(**r[:id]) == pubid }
  else
    index.search { |r| r[:id].exclude(:edition) == pubid }
  end
end