Class: RelatonIso::IsoBibliography
- Inherits:
-
Object
- Object
- RelatonIso::IsoBibliography
- Defined in:
- lib/relaton_iso/iso_bibliography.rb
Overview
Class methods for search ISO standards.
Class Method Summary collapse
-
.get(code, year, opts) ⇒ String
Relaton XML serialisation of reference.
- .search(text) ⇒ RelatonIso::HitPages
Class Method Details
.get(code, year, opts) ⇒ String
Returns Relaton XML serialisation of reference.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/relaton_iso/iso_bibliography.rb', line 32 def get(code, year, opts) %r{ ^(?<code1>[^\s]+\s[^/]+) # match code /? (?<corr>(Amd|DAmd|CD Amd|Cor|CD Cor)\s\d+:?(\d{4})?(/Cor \d+:\d{4})?) # match correction }x =~ code code = code1 if code1 if year.nil? /^(?<code1>[^\s]+\s[\d-]+):?(?<year1>\d{4})?/ =~ code unless code1.nil? code = code1 year = year1 end end code += "-1" if opts[:all_parts] return RelatonIec::IecBibliography.get(code, year, opts) if %r[^ISO/IEC DIR] =~ code ret = isobib_get1(code, year, corr) return nil if ret.nil? ret.to_most_recent_reference unless year || opts[:keep_year] ret.to_all_parts if opts[:all_parts] ret end |
.search(text) ⇒ RelatonIso::HitPages
14 15 16 17 18 19 |
# File 'lib/relaton_iso/iso_bibliography.rb', line 14 def search(text) HitCollection.new text rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError raise RelatonBib::RequestError, "Could not access http://www.iso.org" end |