Module: Pubid::Iho::Identifier

Extended by:
Pubid::IdentifierFacade
Included in:
Pubid::Iho::Identifiers::Base
Defined in:
lib/pubid/iho/identifier.rb

Overview

Entry point for parsing IHO identifiers.

‘extend Pubid::IdentifierFacade` provides polymorphic `from_hash` (routing to the concrete subclass via the `_type` discriminator) and pairs with `include Pubid::Iho::Identifier` in Identifiers::Base for identity (`is_a?`/`===`), so a consumer handed this module can both deserialize and identity-check IHO ids through it.

Class Method Summary collapse

Methods included from Pubid::IdentifierFacade

from_hash, polymorphic_type_map

Class Method Details

.parse(identifier) ⇒ Pubid::Iho::Identifiers::Base

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/identifier.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