Class: RelatonItu::ItuBibliography

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_itu/itu_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 ISO standard Code to look up (e..g “ISO 9000”)

  • year (String) (defaults to: nil)

    the year the standard was published (optional)

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

    options; restricted to :all_parts if all-parts reference is required

Returns:

  • (String)

    Relaton XML serialisation of reference



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/relaton_itu/itu_bibliography.rb', line 32

def get(code, year = nil, opts = {})
  if year.nil?
    /^(?<code1>[^\s]+\s[^\s]+)\s\(\d{2}\/(?<year1>\d+)\)$/ =~ code
    unless code1.nil?
      code = code1
      year = year1
    end
  end

  code += "-1" if opts[:all_parts]
  ret = itubib_get1(code, year, opts)
  return nil if ret.nil?

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

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

Parameters:

  • text (String)

Returns:



20
21
22
23
24
25
26
# File 'lib/relaton_itu/itu_bibliography.rb', line 20

def search(text, year = nil)
  HitCollection.new text, year
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
       Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
       OpenSSL::SSL::SSLError
  raise RelatonBib::RequestError, "Could not access http://www.itu.int"
end