Module: Pubid::Amca
- Defined in:
- lib/pubid/amca.rb,
lib/pubid/amca/parser.rb,
lib/pubid/amca/builder.rb,
lib/pubid/amca/renderer.rb,
lib/pubid/amca/identifier.rb,
lib/pubid/amca/urn_parser.rb,
lib/pubid/amca/identifiers.rb,
lib/pubid/amca/urn_generator.rb,
lib/pubid/amca/identifiers/base.rb,
lib/pubid/amca/single_identifier.rb,
lib/pubid/amca/identifiers/standard.rb,
lib/pubid/amca/identifiers/publication.rb,
lib/pubid/amca/identifiers/interpretation.rb
Defined Under Namespace
Modules: Identifier, Identifiers Classes: Builder, Parser, Renderer, SingleIdentifier, UrnGenerator, UrnParser
Class Method Summary collapse
-
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types.
-
.identifier_types ⇒ Array<Class>
Auto-discover all identifier types from the Identifiers namespace.
-
.locate_stage(abbr) ⇒ Pubid::Components::TypedStage?
Lookup: abbreviation -> typed stage.
-
.locate_type(code) ⇒ Class?
Lookup: type code -> identifier class.
-
.parse(identifier) ⇒ Pubid::Amca::Identifier
Parse an ACMA identifier string into an identifier object.
Class Method Details
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types
37 38 39 40 41 42 43 44 45 |
# File 'lib/pubid/amca.rb', line 37 def self.all_typed_stages @all_typed_stages ||= identifier_types.flat_map do |klass| if klass.const_defined?(:TYPED_STAGES) klass.const_get(:TYPED_STAGES) else [] end end end |
.identifier_types ⇒ Array<Class>
Auto-discover all identifier types from the Identifiers namespace
28 29 30 31 32 33 |
# File 'lib/pubid/amca.rb', line 28 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.singleton_methods(false).include?(:type) } .select { |c| c.type.is_a?(Hash) } end |
.locate_stage(abbr) ⇒ Pubid::Components::TypedStage?
Lookup: abbreviation -> typed stage
57 58 59 60 |
# File 'lib/pubid/amca.rb', line 57 def self.locate_stage(abbr) abbr_str = abbr.to_s.upcase all_typed_stages.find { |s| s.abbr.any? { |a| a.to_s.upcase == abbr_str } } end |
.locate_type(code) ⇒ Class?
Lookup: type code -> identifier class
50 51 52 |
# File 'lib/pubid/amca.rb', line 50 def self.locate_type(code) identifier_types.find { |t| t.type[:key].to_s == code.to_s } end |
.parse(identifier) ⇒ Pubid::Amca::Identifier
Parse an ACMA identifier string into an identifier object
18 19 20 |
# File 'lib/pubid/amca.rb', line 18 def self.parse(identifier) Identifier.parse(identifier) end |