Class: RelatonNist::NistBibliography
- Inherits:
-
Object
- Object
- RelatonNist::NistBibliography
- Defined in:
- lib/relaton_nist/nist_bibliography.rb
Class Method Summary collapse
-
.get(code, year = nil, opts = {}) ⇒ RelatonNist::NistBibliographicItem?
Get NIST document by reference.
-
.search(text, year = nil, opts = {}) ⇒ RelatonNist::HitCollection
Search NIST documents by reference.
Class Method Details
.get(code, year = nil, opts = {}) ⇒ RelatonNist::NistBibliographicItem?
Get NIST document by reference
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/relaton_nist/nist_bibliography.rb', line 39 def get(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity return fetch_ref_err(code, year, []) if code.match?(/\sEP$/) /^(?<code2>[^(]+)(?:\((?<date2>\w+\s(?:\d{2},\s)?\d{4})\))?\s?\(?(?:(?<=\()(?<stage>(?:I|F|\d)PD))?/ =~ code stage ||= /(?<=\.)PD-\w+(?=\.)/.match(code)&.to_s if code2 code = code2.strip if date2 case date2 when /\w+\s\d{4}/ opts[:date] = Date.strptime date2, "%B %Y" when /\w+\s\d{2},\s\d{4}/ opts[:date] = Date.strptime date2, "%B %d, %Y" end end opts[:stage] = stage if stage end if year.nil? /^(?<code1>[^:]+):(?<year1>[^:]+)$/ =~ code unless code1.nil? code = code1 year = year1 end end code += "-1" if opts[:all_parts] nistbib_get(code, year, opts) end |
.search(text, year = nil, opts = {}) ⇒ RelatonNist::HitCollection
Search NIST documents by reference
20 21 22 23 24 25 |
# File 'lib/relaton_nist/nist_bibliography.rb', line 20 def search(text, year = nil, opts = {}) ref = text.sub(/^NISTIR/, "NIST IR") HitCollection.search ref, year, opts rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError => e raise RelatonBib::RequestError, e. end |