Class: Pubid::Gost::Identifier

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

Overview

Base class for all GOST identifiers.

GOST identifiers observed in the wild have the shape:

GOST [R ][<copublisher> ][<subtype> ]<number>[-<year>][/<adopted>][(<refs>)]

Where / is the IDT slash form (modeled by IdenticalAdoption) and () is the parenthesized harmonization list (modeled by Harmonized). A bare InterstateStandard/NationalStandard has neither.

Constant Summary collapse

GOST_TYPE_MAP =
{
  "pubid:gost:interstate-standard" => "Pubid::Gost::Identifiers::InterstateStandard",
  "pubid:gost:national-standard"   => "Pubid::Gost::Identifiers::NationalStandard",
  "pubid:gost:identical-adoption"  => "Pubid::Gost::Identifiers::IdenticalAdoption",
  "pubid:gost:harmonized"          => "Pubid::Gost::Identifiers::Harmonized",
  "pubid:gost:foreign-reference"   => "Pubid::Gost::Identifiers::ForeignReference",
}.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



15
16
17
18
19
20
# File 'lib/pubid/gost/identifier.rb', line 15

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

Instance Method Details

#to_urnObject



44
45
46
# File 'lib/pubid/gost/identifier.rb', line 44

def to_urn
  UrnGenerator.new(self).generate
end