Class: RelatonBsi::BsiBibliography

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bsi/bsi_bibliography.rb

Overview

Class methods for search ISO standards.

Class Method Summary collapse

Class Method Details

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

Returns Relaton XML serialisation of reference.

Parameters:

  • code (String)

    the BSI standard Code to look up

  • year (String) (defaults to: nil)

    the year the standard was published (optional)

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

    options

Options Hash (opts):

  • :all_parts (Boolean)

    if all-parts reference is required

  • :no_year (Boolean)

    if last published document is required

Returns:

  • (String)

    Relaton XML serialisation of reference



35
36
37
38
39
40
41
42
43
44
# File 'lib/relaton_bsi/bsi_bibliography.rb', line 35

def get(code, year = nil, opts = {})
  # y = code.split(":")[1]
  year ||= code_parts(code)[:year]
  ret = bib_get1(code, year, opts)
  return nil if ret.nil?

  ret = ret.to_most_recent_reference unless year || opts[:keep_year]
  # ret = ret.to_all_parts if opts[:all_parts]
  ret
end

.search(text, year = nil) ⇒ RelatonBsi::HitCollection

Parameters:

  • text (String)

Returns:



18
19
20
21
22
23
24
25
# File 'lib/relaton_bsi/bsi_bibliography.rb', line 18

def search(text, year = nil)
  code = text.sub(/^BSI\s/, "")
  HitCollection.new code, year
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
       EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
       Net::ProtocolError, Algolia::AlgoliaUnreachableHostError => e
  raise RelatonBib::RequestError, e.message
end