Module: Pubid::Easc
- Extended by:
- PrefixesSupport
- Defined in:
- lib/pubid/easc.rb,
lib/pubid/easc/parser.rb,
lib/pubid/easc/builder.rb,
lib/pubid/easc/renderer.rb,
lib/pubid/easc/identifier.rb,
lib/pubid/easc/urn_parser.rb,
lib/pubid/easc/identifiers.rb,
lib/pubid/easc/urn_generator.rb,
lib/pubid/easc/identifiers/pmg.rb,
lib/pubid/easc/identifiers/rmg.rb
Defined Under Namespace
Modules: Identifiers Classes: Builder, Identifier, Parser, Renderer, UrnGenerator, UrnParser
Constant Summary collapse
- PREFIXES =
Leading identifier tokens that an EASC document id can start with. Both Cyrillic (canonical — ПМГ, РМГ) and Latin transliterations (PMG, RMG) are accepted; the canonical render is Cyrillic per mgscatalog.by convention.
["ПМГ", "РМГ", "PMG", "RMG"].freeze
Class Method Summary collapse
-
.identifier_klass_for_series(series) ⇒ Class<Identifier>?
Lookup: series (ПМГ / РМГ / PMG / RMG) → identifier class.
-
.identifier_types ⇒ Array<Class>
Auto-discover identifier types from the Identifiers namespace.
- .parse(identifier) ⇒ Pubid::Easc::Identifier
Methods included from PrefixesSupport
Class Method Details
.identifier_klass_for_series(series) ⇒ Class<Identifier>?
Lookup: series (ПМГ / РМГ / PMG / RMG) → identifier class
43 44 45 46 47 48 |
# File 'lib/pubid/easc.rb', line 43 def self.identifier_klass_for_series(series) @by_series ||= identifier_types.to_h do |klass| [klass.type[:series].to_s, klass] end @by_series[series.to_s] || @by_series[series.to_s.upcase] end |
.identifier_types ⇒ Array<Class>
Auto-discover identifier types from the Identifiers namespace.
33 34 35 36 37 38 |
# File 'lib/pubid/easc.rb', line 33 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 |
.parse(identifier) ⇒ Pubid::Easc::Identifier
23 24 25 |
# File 'lib/pubid/easc.rb', line 23 def self.parse(identifier) Identifier.parse(identifier) end |