Class: RelatonItu::RadioRegulationsParser
- Inherits:
-
Object
- Object
- RelatonItu::RadioRegulationsParser
- Includes:
- Relaton::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 ⇒ Object
- #fetch_edition ⇒ Object
- #fetch_link ⇒ Object
- #fetch_relations ⇒ Object
- #fetch_status ⇒ Object
- #fetch_titles ⇒ Object
- #fetch_workgroup ⇒ Object
-
#initialize(hit) ⇒ RadioRegulationsParser
constructor
A new instance of RadioRegulationsParser.
Constructor Details
#initialize(hit) ⇒ RadioRegulationsParser
Returns a new instance of RadioRegulationsParser.
7 8 9 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 7 def initialize(hit) @hit = hit end |
Instance Method Details
#doc ⇒ Object
11 12 13 14 15 16 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 11 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 RelatonBib::RequestError, "Could not access #{doc_url}: #{e.}" end |
#doc_date ⇒ Object
39 40 41 42 43 44 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 39 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
18 19 20 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 18 def doc_url CGI.unescape(hit.hit[:url]).split("dest=").last end |
#fetch_abstract ⇒ Object
25 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 25 def fetch_abstract = [] |
#fetch_dates ⇒ Object
35 36 37 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 35 def fetch_dates array(doc_date).map { |on| { type: "published", on: on } } end |
#fetch_edition ⇒ Object
22 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 22 def fetch_edition = nil |
#fetch_link ⇒ Object
46 47 48 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 46 def fetch_link [RelatonBib::TypedUri.new(type: "src", content: doc_url)] end |
#fetch_relations ⇒ Object
26 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 26 def fetch_relations = [] |
#fetch_status ⇒ Object
23 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 23 def fetch_status = nil |
#fetch_titles ⇒ Object
28 29 30 31 32 33 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 28 def fetch_titles title = doc.at("//title")&.text&.strip return [] if title.nil? || title.empty? RelatonBib::TypedTitleString.from_string title, "en", "Latn" end |
#fetch_workgroup ⇒ Object
24 |
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 24 def fetch_workgroup = nil |