Class: RelatonIec::IecBibliography
- Inherits:
-
Object
- Object
- RelatonIec::IecBibliography
- Defined in:
- lib/relaton_iec/iec_bibliography.rb
Overview
Class methods for search ISO standards.
Class Method Summary collapse
-
.get(code, year = nil, opts = {}) ⇒ String
Relaton XML serialisation of reference.
-
.search(text, year = nil, part = nil) ⇒ RelatonIec::HitCollection
Search for standards entries.
Class Method Details
.get(code, year = nil, opts = {}) ⇒ String
Returns Relaton XML serialisation of reference.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/relaton_iec/iec_bibliography.rb', line 34 def get(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity opts[:all_parts] ||= code.match? /\s\(all parts\)/ ref = code.sub /\s\(all parts\)/, "" if year.nil? /^(?<code1>[^:]+):(?<year1>[^:]+)/ =~ ref unless code1.nil? ref = code1 year = year1 end end return iev if ref.casecmp("IEV").zero? ret = iecbib_get(ref, year, opts) return nil if ret.nil? ret = ret.to_most_recent_reference unless year || opts[:keep_year] ret end |
.search(text, year = nil, part = nil) ⇒ RelatonIec::HitCollection
Search for standards entries. To seach packaged document it needs to pass part parametr.
23 24 25 26 27 |
# File 'lib/relaton_iec/iec_bibliography.rb', line 23 def search(text, year = nil, part = nil) HitCollection.new text.sub(/(^\w+)\//, '\1 '), year&.strip, part rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError raise RelatonBib::RequestError, "Could not access http://www.iec.ch" end |