Class: Relaton::Itu::RadioRegulationsParser
- Inherits:
-
Object
- Object
- Relaton::Itu::RadioRegulationsParser
- Includes:
- Core::ArrayWrapper
- Defined in:
- lib/relaton/itu/radio_regulations_parser.rb
Constant Summary collapse
- ROMAN_MONTHS =
%w[I II III IV V VI VII VIII IX X XI XII].freeze
Instance Method Summary collapse
- #doc ⇒ Object
- #doc_date ⇒ Object
- #doc_url ⇒ Object
- #fetch_abstract ⇒ Object
- #fetch_dates ⇒ Array<Relaton::Bib::Date>
- #fetch_edition ⇒ Object
- #fetch_relations ⇒ Object
- #fetch_source ⇒ Array<Relaton::Bib::Uri>
- #fetch_status ⇒ Object
- #fetch_titles ⇒ Array<Relaton::Bib::Title>
- #fetch_workgroup ⇒ Object
-
#initialize(hit) ⇒ RadioRegulationsParser
constructor
A new instance of RadioRegulationsParser.
Constructor Details
#initialize(hit) ⇒ RadioRegulationsParser
Returns a new instance of RadioRegulationsParser.
10 11 12 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 10 def initialize(hit) @hit = hit end |
Instance Method Details
#doc ⇒ Object
14 15 16 17 18 19 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 14 def doc @doc ||= hit.hit_collection.agent.get doc_url rescue Mechanize::ResponseCodeError, SocketError, Timeout::Error, Errno::ECONNRESET, EOFError, Net::ProtocolError, OpenSSL::SSL::SSLError => e raise Relaton::RequestError, "Could not access #{doc_url}: #{e.}" end |
#doc_date ⇒ Object
44 45 46 47 48 49 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 44 def doc_date return @doc_date if defined? @doc_date date_str = doc.at("//td[@class='title']/text()")&.text&.slice(/(?<=Year:\s)(?:\d{1,2}\.\w+\.)?\d{4}/) @doc_date = date_str ? roman_to_arabic(date_str) : nil end |
#doc_url ⇒ Object
21 22 23 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 21 def doc_url CGI.unescape(hit.hit[:url]).split("dest=").last end |
#fetch_abstract ⇒ Object
27 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 27 def fetch_abstract = [] |
#fetch_dates ⇒ Array<Relaton::Bib::Date>
40 41 42 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 40 def fetch_dates array(doc_date).map { |on| Relaton::Bib::Date.new(type: "published", at: on) } end |
#fetch_edition ⇒ Object
25 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 25 def fetch_edition = nil |
#fetch_relations ⇒ Object
28 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 28 def fetch_relations = [] |
#fetch_source ⇒ Array<Relaton::Bib::Uri>
52 53 54 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 52 def fetch_source [Relaton::Bib::Uri.new(type: "src", content: doc_url)] end |
#fetch_status ⇒ Object
26 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 26 def fetch_status = nil |
#fetch_titles ⇒ Array<Relaton::Bib::Title>
32 33 34 35 36 37 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 32 def fetch_titles title = doc.at("//title")&.text&.strip return [] if title.nil? || title.empty? Relaton::Bib::Title.from_string title, "en", "Latn" end |
#fetch_workgroup ⇒ Object
29 |
# File 'lib/relaton/itu/radio_regulations_parser.rb', line 29 def fetch_workgroup = nil |