Class: Pubid::Astm::UrnParser

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

Overview

Parses ASTM URNs back into identifiers.

UrnGenerator emits:

urn:astm:{publisher}:{code}:{year}[:sub_year][:reapp.X][:eX][:wip][:wk.X]

The publisher slot is the lowercase publisher string (“astm” or “pub-copub”). The code slot is the alphanumeric ASTM code (e.g., “D2148”, “A1”). Year is **2 digits** in the URN.

Examples:

  • urn:astm:astm:D2148:2022 → ASTM D2148-22

  • urn:astm:astm:A1:2002 → ASTM A1-02

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#parse_urn(urn) ⇒ Object



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

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

  _publisher, code, year = parts

  text = "ASTM #{code}"
  text += "-#{year[-2..]}" if year && year.length >= 2
  flavor_parse(text)
end