Class: RelatonIec::IecBibliography

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_iec/iec_bibliography.rb

Overview

Class methods for search IEC standards.

Class Method Summary collapse

Class Method Details

.get(code, year = nil, opts = {}) ⇒ RelatonIec::IecBibliographicItem?

Parameters:

  • code (String)

    the IEC standard code to look up (e.g. “IEC 8000”)

  • 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:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/relaton_iec/iec_bibliography.rb', line 27

def get(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
  opts[:all_parts] ||= code.match?(/\s\(all parts\)/)
  ref = code.sub(/\s\(all parts\)/, "")
  return iev if ref.casecmp("IEV").zero?

  pubid = Pubid::Iec::Identifier.parse ref.upcase
  pubid.year = year.to_i if year

  ret = iecbib_get(pubid, opts)
  return nil if ret.nil?

  ret = ret.to_most_recent_reference unless pubid.year || opts[:keep_year] ||
    opts[:publication_date_before] || opts[:publication_date_after]
  ret
end

.search(pubid, exclude: [:year]) ⇒ RelatonIec::HitCollection

Search for standards entries.

Parameters:

  • pubid (Pubid::Iec::Identifier)
  • exclude (Array<Symbol>) (defaults to: [:year])

    keys to exclude from comparison

Returns:



16
17
18
19
20
# File 'lib/relaton_iec/iec_bibliography.rb', line 16

def search(pubid, exclude: [:year])
  HitCollection.new pubid, exclude: exclude
rescue SocketError, OpenSSL::SSL::SSLError => e
  raise RelatonBib::RequestError, e.message
end