Class: Pubid::Tgpp::UrnParser

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

Overview

Parses 3GPP URNs back into identifiers.

UrnGenerator emits urn:3gpp:<type>:<code>:<release>:<version>; the code, release and version chunks never contain ":", so a plain split recovers them. Example: urn:3gpp:ts:23.207:REL-4:2.0.0 → TS 23.207:REL-4/2.0.0

Instance Method Summary collapse

Methods inherited from UrnParser::Base

parse

Instance Method Details

#flavor_nameObject

The module is Tgpp but the URN namespace is "3gpp".



12
13
14
# File 'lib/pubid/tgpp/urn_parser.rb', line 12

def flavor_name
  "3gpp"
end

#parse_urn(urn) ⇒ Object



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

def parse_urn(urn)
  body = strip_namespace(urn)
  type, code, release, version = split_parts(body)
  # The rare no-release form (e.g. TS 29.215/2.0.0) serialises with an
  # empty release chunk ("urn:3gpp:ts:29.215::2.0.0"); rebuild it without
  # the release colon.
  head = "#{type.upcase} #{code}"
  head += ":#{release}" unless release.nil? || release.empty?
  flavor_parse("#{head}/#{version}")
end