Class: Pubid::Easc::Identifier

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

Overview

Base class for all EASC identifiers. Canonical name Pubid::Easc::Identifier; every concrete EASC identifier (Identifiers::*) descends from it.

EASC identifiers have the form:

<series> [В ]<number>[-<year>]

Where:

* <series> identifies the document class — ПМГ (Правила
межгосударственной стандартизации) or РМГ (Рекомендации по
межгосударственной стандартизации). Latin forms PMG/RMG are
also parsed; canonical render is Cyrillic per mgscatalog.by.
* the optional "В" (Cyrillic capital V) marks a defense-related
variant (e.g. "ПМГ В 31-2001"). Stored as `variant: "V"`
(Latin) for cross-script consistency.
* <number> is a digit run.
* <year> is 2 or 4 digits, separated by ASCII hyphen OR Unicode
em-dash / en-dash (Russian typographic convention).

Examples:

ПМГ 03-2025
ПМГ В 31-2001
РМГ 151-2025
РМГ 29-2013

Constant Summary collapse

EASC_TYPE_MAP =
{
  "pubid:easc:pmg" => "Pubid::Easc::Identifiers::Pmg",
  "pubid:easc:rmg" => "Pubid::Easc::Identifiers::Rmg",
}.freeze

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_name, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_s, #to_slug, #to_supplement_s, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.parse(identifier) ⇒ Object



30
31
32
33
34
35
# File 'lib/pubid/easc/identifier.rb', line 30

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

Instance Method Details

#to_urnObject



56
57
58
# File 'lib/pubid/easc/identifier.rb', line 56

def to_urn
  UrnGenerator.new(self).generate
end