Class: Relaton::Cen::Bibliography
- Inherits:
-
Object
- Object
- Relaton::Cen::Bibliography
- Defined in:
- lib/relaton/cen/bibliography.rb
Overview
Class methods for search Cenelec standards.
Class Method Summary collapse
-
.code_to_parts(code) ⇒ MatchData
Decopmposes a CEN standard code into its parts.
- .get(code, year = nil, opts = {}) ⇒ RelatonBib::BibliographicItem?
- .search(text, year = nil) ⇒ RelatonCen::HitCollection
Class Method Details
.code_to_parts(code) ⇒ MatchData
Decopmposes a CEN standard code into its parts.
39 40 41 42 43 44 45 46 |
# File 'lib/relaton/cen/bibliography.rb', line 39 def code_to_parts(code) %r{^ (?<code>[^:-]+)(?:-(?<part>\d+))? (?::(?<year>\d{4}))? (?:\+(?<amd>[A-Z]\d+)(?:(?<amy>\d{4}))?)? (?:\/(?<ac>AC\d+:\d{4}))? }x.match code end |
.get(code, year = nil, opts = {}) ⇒ RelatonBib::BibliographicItem?
25 26 27 28 29 30 |
# File 'lib/relaton/cen/bibliography.rb', line 25 def get(code, year = nil, opts = {}) code_parts = code_to_parts code year ||= code_parts[:year] if code_parts bib_get(code, year, opts) end |
.search(text, year = nil) ⇒ RelatonCen::HitCollection
10 11 12 13 14 15 |
# File 'lib/relaton/cen/bibliography.rb', line 10 def search(text, year = nil) # /^C?EN\s(?<code>.+)/ =~ text HitCollection.new(text, year).search rescue Mechanize::ResponseCodeError, Net::ReadTimeout => e raise Relaton::RequestError, e. end |