Class: RelatonCen::CenBibliography
- Inherits:
-
Object
- Object
- RelatonCen::CenBibliography
- Defined in:
- lib/relaton_cen/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.
38 39 40 41 42 43 44 45 |
# File 'lib/relaton_cen/cen_bibliography.rb', line 38 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?
24 25 26 27 28 29 |
# File 'lib/relaton_cen/cen_bibliography.rb', line 24 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
9 10 11 12 13 14 |
# File 'lib/relaton_cen/cen_bibliography.rb', line 9 def search(text, year = nil) # /^C?EN\s(?<code>.+)/ =~ text HitCollection.new text, year rescue Mechanize::ResponseCodeError => e raise RelatonBib::RequestError, e. end |