Class: RelatonOgc::OgcBibliography

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_ogc/ogc_bibliography.rb

Class Method Summary collapse

Class Method Details

.get(code, year = nil, opts = {}) ⇒ String

Returns Relaton XML serialisation of reference.

Parameters:

  • code (String)

    the OGC standard Code to look up (e..g “8200”)

  • year (String) (defaults to: nil)

    the year the standard was published (optional)

  • opts (Hash) (defaults to: {})

    options

Options Hash (opts):

  • :all_parts (TrueClass, FalseClass)

    restricted to all parts if all-parts reference is required

  • :bibdata (TrueClass, FalseClass)

Returns:

  • (String)

    Relaton XML serialisation of reference



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/relaton_ogc/ogc_bibliography.rb', line 22

def get(code, year = nil, opts = {})
  # id = year ? "`#{code}` year `#{year}`" : "#`{code}`"
  result = bib_search_filter(code, year, opts) || (return nil)
  ret = bib_results_filter(result, year)
  if ret[:ret]
    Util.info "Found: `#{ret[:ret].docidentifier.first.id}`", key: code
    ret[:ret]
  else
    fetch_ref_err(code, year, ret[:years])
  end
end

.search(text, year = nil, _opts = {}) ⇒ RelatonOgc::HitCollection

Parameters:

  • text (String)

Returns:



6
7
8
9
10
11
# File 'lib/relaton_ogc/ogc_bibliography.rb', line 6

def search(text, year = nil, _opts = {})
  code = text.sub(/^OGC\s/, "")
  HitCollection.new code, year
rescue Faraday::ConnectionFailed, Faraday::SSLError
  raise RelatonBib::RequestError, HitCollection::ENDPOINT
end