Class: Pubid::Amca::UrnParser

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

Overview

Parses AMCA URNs back into identifiers.

UrnGenerator emits:

urn:amca:{number}:{year}[:{copub.publisher}[:{other tokens}]]

The current generator can leak the Type Hash literal into the URN (e.g., ‘copub.amca:=> :standard, …`). This parser filters any token containing `{` so round-trip works for the common case.

Examples:

  • urn:amca:210:08 → AMCA 210-08

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/amca/urn_parser.rb', line 17

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

  number, year = parts
  text = "AMCA #{number}"
  text += "-#{year}" if year
  flavor_parse(text)
end