Class: Pubid::Iho::Identifier

Inherits:
Pubid::Identifier show all
Defined in:
lib/pubid/iho/identifiers/base.rb

Overview

Base class for all IHO identifiers. Canonical name Pubid::Iho::Identifier; every concrete IHO identifier (Identifiers::*) descends from it, and Identifiers::Base — aliased at the foot of this file — points back to it.

IHO identifiers have the form:

IHO {S|P|M|B|C}-{number}[ Ap. {appendix}][ Part {part}][ Annex {annex}][ Suppl {supplement}][ {version}]

The leading IHO publisher prefix is optional on input but always emitted on output.

Constant Summary collapse

IHO_TYPE_MAP =

Polymorphic type map for lutaml::Model key_value serialization: maps each subclass's polymorphic_name to its class name so from_hash can re-instantiate the concrete type from _type.

{
  "pubid:iho:standard" => "Pubid::Iho::Identifiers::Standard",
  "pubid:iho:publication" => "Pubid::Iho::Identifiers::Publication",
  "pubid:iho:miscellaneous" => "Pubid::Iho::Identifiers::Miscellaneous",
  "pubid:iho:bibliographic" => "Pubid::Iho::Identifiers::Bibliographic",
  "pubid:iho:circular-letter" => "Pubid::Iho::Identifiers::CircularLetter",
}.freeze

Class Method Summary collapse

Methods inherited from Pubid::Identifier

#base_identifier, #eql?, #exclude, from_hash, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #render, #resolve_urn_generator, #root, #to_hash, #to_mr_string, #to_s, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.parse(identifier) ⇒ Pubid::Iho::Identifier

Parse an IHO identifier string into an identifier object

Parameters:

  • identifier (String)

    The IHO identifier string to parse

Returns:

Raises:

  • (Parslet::ParseFailed)

    If parsing fails



19
20
21
22
23
24
# File 'lib/pubid/iho/identifiers/base.rb', line 19

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