Class: RelatonGb::GbBibliography
- Inherits:
-
Object
- Object
- RelatonGb::GbBibliography
- Defined in:
- lib/relaton_gb/gb_bibliography.rb
Overview
GB entry point class.
Class Method Summary collapse
-
.get(code, year = nil, opts = {}) ⇒ String
Relaton XML serialisation of reference.
-
.search(text) ⇒ RelatonGb::HitCollection
rubocop:disable Metrics/MethodLength.
Class 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_gb/gb_bibliography.rb', line 43 def get(code, year = nil, opts = {}) if year.nil? /^(?<code1>[^-]+)-(?<year1>[^-]+)$/ =~ code unless code1.nil? code = code1 year = year1 end end code += ".1" if opts[:all_parts] code, year = code.split(/-/, 2) if /-/ =~ code ret = get1(code, year, opts) return nil if ret.nil? ret = ret.to_most_recent_reference unless year ret = ret.to_all_parts if opts[:all_parts] ret end |
.search(text) ⇒ RelatonGb::HitCollection
rubocop:disable Metrics/MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/relaton_gb/gb_bibliography.rb', line 16 def search(text) if text =~ /^(GB|GJ|GS)/ # Scrape national standards. require "relaton_gb/gb_scrapper" GbScrapper.scrape_page text elsif text =~ /^ZB/ # Scrape proffesional. elsif text =~ /^DB/ # Scrape local standard. elsif text =~ %r{^Q\/} # Enterprise standard elsif text =~ %r{^T\/[^\s]{3,6}\s} # Scrape social standard. require "relaton_gb/t_scrapper" TScrapper.scrape_page text else # Scrape sector standard. require "relaton_gb/sec_scrapper" SecScrapper.scrape_page text end end |