Class: RelatonUn::UnBibliography

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_un/un_bibliography.rb

Overview

Class methods for search ISO standards.

Class Method Summary collapse

Class Method Details

.get(ref, _year = nil, _opts = {}) ⇒ RelatonUn::UnBibliographicItem

Parameters:

  • ref (String)

    document reference

  • year (String, NilClass)
  • opts (Hash)

    options

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/relaton_un/un_bibliography.rb', line 23

def get(ref, _year = nil, _opts = {})
  Util.info "Fetching from documents.un.org ...", key: ref
  /^(?:UN\s)?(?<code>.*)/ =~ ref
  result = isobib_search_filter(code)
  if result
    Util.info "Found: `#{result.fetch.docidentifier[0].id}`", key: ref
    result.fetch
  else
    Util.info "Not found.", key: ref
    nil
  end
end

.search(text) ⇒ RelatonUn::HitCollection

Parameters:

  • text (String)

Returns:



9
10
11
12
13
14
15
16
17
# File 'lib/relaton_un/un_bibliography.rb', line 9

def search(text)
  HitCollection.new text
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
       Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
       Net::ProtocolError, Net::ReadTimeout, Net::OpenTimeout,
       OpenSSL::SSL::SSLError, Errno::ETIMEDOUT => e
  raise RelatonBib::RequestError,
        "Could not access #{HitCollection::DOMAIN}: #{e.message}"
end