Class: Pubid::Iala::Identifier

Inherits:
Pubid::Identifier show all
Defined in:
lib/pubid/iala/identifier.rb

Overview

Base class for all IALA identifiers. Canonical name Pubid::Iala::Identifier; every concrete IALA identifier (Identifiers::*) descends from it, and Identifiers::Base — aliased at the foot of identifiers/base.rb — points back to it.

IALA identifiers have the form:

[IALA ]{S|R|G|M|C|X|P}<4-digit number>[-<subpart>][ Ed <edition>][ (<LangLetter>)]

Examples:

S1070
IALA S1070 Ed 2.0
R1016:ed2.0(F)
C0103-1 Ed 3.0

Constant Summary collapse

IALA_TYPE_MAP =
{
  "pubid:iala:standard"       => "Pubid::Iala::Identifiers::Standard",
  "pubid:iala:recommendation" => "Pubid::Iala::Identifiers::Recommendation",
  "pubid:iala:guideline"      => "Pubid::Iala::Identifiers::Guideline",
  "pubid:iala:manual"         => "Pubid::Iala::Identifiers::Manual",
  "pubid:iala:model-course"   => "Pubid::Iala::Identifiers::ModelCourse",
  "pubid:iala:report"         => "Pubid::Iala::Identifiers::Report",
  "pubid:iala:resolution"     => "Pubid::Iala::Identifiers::Resolution",
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pubid::Identifier

#base_document, #base_identifier, #drop_supplements, #eql?, #exclude, from_hash, #hash, #initialize, #matches?, #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, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

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

Parse an IALA identifier string into an identifier object.

Parameters:

  • identifier (String)

Returns:

Raises:

  • (Parslet::ParseFailed)

    If parsing fails



23
24
25
26
27
28
# File 'lib/pubid/iala/identifier.rb', line 23

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

Instance Method Details

#to_urnObject



52
53
54
# File 'lib/pubid/iala/identifier.rb', line 52

def to_urn
  UrnGenerator.new(self).generate
end

#type_letterObject

Single-letter type code (S, R, G, …) — convenience accessor used by Renderer and UrnGenerator.



58
59
60
# File 'lib/pubid/iala/identifier.rb', line 58

def type_letter
  self.class.type[:short]
end