Class: Pubid::Asme::UrnParser

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

Overview

Parses ASME URNs back into identifiers.

UrnGenerator emits:

urn:asme:{publisher}:{code}:{year}

publisher is the lowercase publisher string. code is the alphanumeric designation (e.g., “B16.5”, “PTC1”, “BPVC-2023”). The year separator in human-readable form is ‘-`, not `:`.

Examples:

  • urn:asme:asme:B16.5:2020 → ASME B16.5-2020

  • urn:asme:asme:PTC1:2020 → ASME PTC1-2020

  • urn:asme:asme:BPVC-2023 → ASME BPVC-2023

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/pubid/asme/urn_parser.rb', line 19

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

  _publisher, code, year = parts

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