Module: RelatonCcsds::Bibliography

Extended by:
Bibliography
Included in:
Bibliography
Defined in:
lib/relaton_ccsds/bibliography.rb

Instance Method Summary collapse

Instance Method Details

#get(reference, _year = nil, opts = {}) ⇒ RelatonCcsds::BibliographicItem

Get CCSDS standard by document reference. If format is not specified, then all format will be returned.

Parameters:

  • reference (String)
  • year (String, nil)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :format (String)

    format of fetched document (DOC, PDF)

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/relaton_ccsds/bibliography.rb', line 27

def get(reference, _year = nil, opts = {}) # rubocop:disable Metrics/MethodLength
  ref = reference.sub(/\s\((DOC|PDF)\)$/, "")
  opts[:format] ||= Regexp.last_match(1)
  Util.info "Fetching from Relaton repository ...", key: reference
  hits = search ref
  doc = hits.first&.doc&.to_format(opts[:format])
  unless doc
    Util.info "Not found.", key: reference
    return nil
  end
  Util.info "Found: `#{hits.first.code}`.", key: reference
  doc
end

#search(ref) ⇒ RelatonCcsds::HitCollection

Search for CCSDS standards by document reference.

Parameters:

  • ref (String)

    document reference

Returns:



12
13
14
# File 'lib/relaton_ccsds/bibliography.rb', line 12

def search(ref)
  RelatonCcsds::HitCollection.new(ref).fetch
end