Class: Pubid::Cie::UrnParser

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

Overview

Parses CIE URNs back into identifiers.

UrnGenerator emits:

urn:cie:cie:{code}:{year}:sep.colon

The trailing ‘sep.colon` token records the code/year separator used in the human-readable form (`:`). The leading `cie` after the namespace is the lowercase publisher.

Examples:

  • urn:cie:cie:015:2018:sep.colon → CIE 015:2018

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/pubid/cie/urn_parser.rb', line 17

def parse_urn(urn)
  body = strip_namespace(urn)
  parts = split_parts(body).reject { |p| p.start_with?("sep.") }

  _publisher, code, year = parts
  text = "CIE #{code}"
  text += ":#{year}" if year
  flavor_parse(text)
end