Module: Pubid::Adobe

Extended by:
PrefixesSupport
Defined in:
lib/pubid/adobe.rb,
lib/pubid/adobe/parser.rb,
lib/pubid/adobe/builder.rb,
lib/pubid/adobe/renderer.rb,
lib/pubid/adobe/identifier.rb,
lib/pubid/adobe/urn_parser.rb,
lib/pubid/adobe/identifiers.rb,
lib/pubid/adobe/urn_generator.rb,
lib/pubid/adobe/identifiers/tech_note.rb,
lib/pubid/adobe/identifiers/publication.rb

Defined Under Namespace

Modules: Identifiers Classes: Builder, Identifier, Parser, Renderer, UrnGenerator, UrnParser

Constant Summary collapse

PREFIXES =

Leading identifier prefix tokens that an Adobe document id can start with. Tech notes appear as both Adobe Technical Note #<n> and the short alias ATN<n> in citations; both must route to this flavor. Named publications start with Adobe (e.g. Adobe Glyph List, Adobe-Japan1-7).

["Adobe", "ATN"].freeze

Class Method Summary collapse

Methods included from PrefixesSupport

prefix_flavor_key, prefixes

Class Method Details

.identifier_klass_for_short(short) ⇒ Class<Identifier>

Lookup: type short letter (e.g. "ATN") → identifier class

Parameters:

  • short (String)

Returns:



53
54
55
56
# File 'lib/pubid/adobe.rb', line 53

def self.identifier_klass_for_short(short)
  @by_short ||= identifier_types.to_h { |klass| [klass.type[:short].to_s, klass] }
  @by_short.fetch(short.to_s)
end

.identifier_typesArray<Class>

Auto-discover identifier types from the Identifiers namespace.

Returns:

  • (Array<Class>)


36
37
38
39
40
41
# File 'lib/pubid/adobe.rb', line 36

def self.identifier_types
  @identifier_types ||= Identifiers.constants
    .filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end }
    .select { |c| c.is_a?(Class) && c < Pubid::Identifier }
    .reject { |c| c == Identifier }
end

.locate_type(code) ⇒ Class?

Lookup: type key → identifier class

Parameters:

  • code (String, Symbol)

Returns:

  • (Class, nil)


46
47
48
# File 'lib/pubid/adobe.rb', line 46

def self.locate_type(code)
  identifier_types.find { |t| t.type[:key].to_s == code.to_s }
end

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

Parse an Adobe identifier string into an identifier object.

Parameters:

  • identifier (String)

Returns:



25
26
27
# File 'lib/pubid/adobe.rb', line 25

def self.parse(identifier)
  Identifier.parse(identifier)
end