Class: RelatonItu::RadioRegulationsParser

Inherits:
Object
  • Object
show all
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

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

#docObject



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.message}"
end

#doc_dateObject



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_urlObject



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_abstractObject



25
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 25

def fetch_abstract = []

#fetch_datesObject



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_editionObject



22
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 22

def fetch_edition = nil


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_relationsObject



26
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 26

def fetch_relations = []

#fetch_statusObject



23
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 23

def fetch_status = nil

#fetch_titlesObject



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_workgroupObject



24
# File 'lib/relaton_itu/radio_regulations_parser.rb', line 24

def fetch_workgroup = nil