Class: Pubid::Tgpp::Identifier

Inherits:
Identifier
  • Object
show all
Defined in:
lib/pubid/tgpp/identifier.rb

Overview

Base class for every 3GPP identifier AND the flavor's parse entry point — mirrors Pubid::Jis::Identifier. Concrete identifiers under Pubid::Tgpp::Identifiers descend from this class, so a parsed 3GPP id is an instance of Pubid::Tgpp::Identifier.

Constant Summary collapse

TGPP_TYPE_MAP =

Polymorphic type map for lutaml::Model key_value (de)serialization. Keys are the pubid:3gpp:… names produced by polymorphic_name (below).

{
  "pubid:3gpp:technical-report" =>
    "Pubid::Tgpp::Identifiers::TechnicalReport",
  "pubid:3gpp:technical-specification" =>
    "Pubid::Tgpp::Identifiers::TechnicalSpecification",
}.freeze
PUBLISHER =

Publisher token. A plain constant (not a publisher method) so it does not shadow the inherited lutaml publisher attribute.

"3GPP"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Identifier

apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, #exclude, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_languages, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_type, #mr_year, #new_edition_of?, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Attribute Details

#with_publisherObject (readonly)

Rendering flag: whether to prefix the string with "3GPP ". Transient (not serialized). #to_s sets it, renders, then resets it to false in an ensure block, so a subsequent bare #render defaults to no publisher and the flag never leaks past the to_s call that set it.



57
58
59
# File 'lib/pubid/tgpp/identifier.rb', line 57

def with_publisher
  @with_publisher
end

Class Method Details

.parse(identifier) ⇒ Identifier

Parse a 3GPP identifier string into an identifier object

Parameters:

  • identifier (String)

    The 3GPP identifier string to parse

Returns:

  • (Identifier)

    The appropriate identifier object



79
80
81
82
83
84
85
86
87
88
# File 'lib/pubid/tgpp/identifier.rb', line 79

def self.parse(identifier)
  if identifier.length > Pubid::MAX_INPUT_LENGTH
    raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
  end

  parsed = Parser.parse(identifier)
  Builder.build(parsed)
rescue Parslet::ParseFailed => e
  raise "Failed to parse 3GPP identifier '#{identifier}': #{e.message}"
end

.polymorphic_nameObject

The auto-derived polymorphic name would be "pubid:tgpp:…" (from the module constant). Force the "3gpp" segment so the _type tag matches the relaton flavor name and TGPP_TYPE_MAP.



49
50
51
# File 'lib/pubid/tgpp/identifier.rb', line 49

def self.polymorphic_name
  super&.sub(/\Apubid:tgpp:/, "pubid:3gpp:")
end

Instance Method Details

#codeObject

The rendered document code, e.g. "29.198-04-1" (number+suffix+parts).



60
61
62
63
64
# File 'lib/pubid/tgpp/identifier.rb', line 60

def code
  result = "#{number}#{suffix}"
  result += parts.map { |p| "-#{p}" }.join if parts&.any?
  result
end

#to_s(with_publisher: false, **opts) ⇒ Object

Basic string representation. Delegates to the :human renderer. Default omits the "3GPP " publisher token (matches the relaton index id); to_s(with_publisher: true) emits the printed "3GPP TS …" form.



69
70
71
72
73
74
# File 'lib/pubid/tgpp/identifier.rb', line 69

def to_s(with_publisher: false, **opts)
  @with_publisher = with_publisher
  render(format: :human, **opts)
ensure
  @with_publisher = false
end