Class: Pubid::Ieee::UrnParser

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

Overview

Parses IEEE URNs back into identifiers.

UrnGenerator emits many fields; this parser handles the common published-standard shape:

urn:ieee:{publisher}:{code}:{year}

publisher is the lowercase publisher (with optional copublishers joined by ‘-`). code is the alphanumeric designation (period is the part separator within the code). The year separator in human-readable form is `-`.

Examples:

  • urn:ieee:ieee:802.3:2018 → IEEE Std 802.3-2018

  • urn:ieee:ieee:1018:2019 → IEEE Std 1018-2019

Constant Summary collapse

PUBLISHER_LABEL =
"IEEE"

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/pubid/ieee/urn_parser.rb', line 22

def parse_urn(urn)
  body = strip_namespace(urn)
  parts = split_parts(body)

  _publisher, code, year = parts

  text = "#{PUBLISHER_LABEL} Std #{code}"
  text += "-#{year}" if year
  flavor_parse(text)
end