Module: Pubid::Amca::Identifier

Defined in:
lib/pubid/amca/identifier.rb

Class Method Summary collapse

Class Method Details

.create(type: nil, **opts) ⇒ Object

Factory that builds an AMCA identifier from a hash of primitives.

Dispatch on ‘:type`:

* `:standard` (default) → Identifiers::Standard
* `:publication`        → Identifiers::Publication
* `:interpretation`     → Identifiers::Interpretation

AMCA stores the “AMCA” prefix in the ‘copublisher` string attribute (matching parsed output); `.create` defaults it to “AMCA” unless the caller supplies one.



27
28
29
30
# File 'lib/pubid/amca/identifier.rb', line 27

def self.create(type: nil, **opts)
  klass = resolve_create_class(type)
  klass.new(**coerce_create_attrs(opts))
end

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

Parse an ACMA identifier string into an identifier object

Parameters:

  • identifier (String)

    The ACMA identifier string to parse

Returns:

Raises:

  • (Parslet::ParseFailed)

    If parsing fails



10
11
12
13
14
15
# File 'lib/pubid/amca/identifier.rb', line 10

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