Class: Pubid::Itu::UrnParser

Inherits:
UrnParser::Base show all
Defined in:
lib/pubid/itu/urn_parser.rb

Overview

Parses ITU URNs back into identifiers.

UrnGenerator emits: urn:itu:{sector}:{code} where sector is the lowercase ITU sector letter (t for ITU-T, r for ITU-R, d for ITU-D) and code is the document code (e.g., "BO.1073-1").

Examples:

  • urn:itu:t:BO.1073-1 → ITU-T BO.1073-1
  • urn:itu:r:BO.500 → ITU-R BO.500

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pubid/itu/urn_parser.rb', line 15

def parse_urn(urn)
  body = strip_namespace(urn)
  parts = split_parts(body)
  sector, code = parts

  # UrnGenerator emits a "report" segment between the sector and the code
  # for an ITU-R Report, which numbers independently of the
  # Recommendation series (urn:itu:r:report:BT.2020-1).
  if parts[1] == "report"
    return flavor_parse("Report ITU-#{sector.upcase} #{parts[2]}")
  end

  flavor_parse("ITU-#{sector.upcase} #{code}")
end