Class: Relaton::Iec::Bibliography

Inherits:
Object
  • Object
show all
Extended by:
Core::ArrayWrapper
Defined in:
lib/relaton/iec/bibliography.rb

Overview

Class methods for search IEC standards.

Constant Summary collapse

DOCTYPES =
%w[TS TR PAS SRD TEC STTR WP Guide OD CS CA].freeze

Class Method Summary collapse

Class Method Details

.get(code, year = nil, opts = {}) ⇒ Relaton::Iec::ItemData?

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:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/relaton/iec/bibliography.rb', line 32

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]) ⇒ Relaton::Iec::HitCollection

Search for standards entries.

Parameters:

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

    keys to exclude from comparison

Returns:



21
22
23
24
25
# File 'lib/relaton/iec/bibliography.rb', line 21

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