Module: RelatonItu::ItuBibliography
- Extended by:
- ItuBibliography
- Included in:
- ItuBibliography
- Defined in:
- lib/relaton_itu/itu_bibliography.rb
Overview
Class methods for search ISO standards.
Instance Method Summary collapse
-
#get(code, year = nil, opts = {}) ⇒ String
Relaton XML serialisation of reference.
- #search(refid) ⇒ RelatonItu::HitCollection
Instance Method Details
#get(code, year = nil, opts = {}) ⇒ String
Returns Relaton XML serialisation of reference.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/relaton_itu/itu_bibliography.rb', line 43 def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity refid = Pubid.parse code refid.year ||= year # if year.nil? # /^(?<code1>[^\s]+\s[^\s]+)\s\((?:\d{2}\/)?(?<year1>\d+)\)$/ =~ code # unless code1.nil? # code = code1 # year = year1 # end # end ret = itubib_get1(refid) return nil if ret.nil? ret = ret.to_most_recent_reference unless refid.year || opts[:keep_year] ret = ret.to_all_parts if opts[:all_parts] ret end |
#search(refid) ⇒ RelatonItu::HitCollection
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/relaton_itu/itu_bibliography.rb', line 22 def search(refid) refid = RelatonItu::Pubid.parse refid if refid.is_a? String if refid.to_ref =~ /(ITU[\s-]T\s\w)\.(Suppl\.|Annex)\s?(\w?\d+)/ correct_ref = "#{$~[1]} #{$~[2]} #{$~[3]}" Util.info "Incorrect reference: `#{refid}`, the reference should be: `#{correct_ref}`" end HitCollection.new refid rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, URI::InvalidURIError => e raise RelatonBib::RequestError, e. end |