Module: Pubid::Oiml
- Defined in:
- lib/pubid/oiml.rb,
lib/pubid/oiml/parser.rb,
lib/pubid/oiml/builder.rb,
lib/pubid/oiml/renderer.rb,
lib/pubid/oiml/components.rb,
lib/pubid/oiml/identifier.rb,
lib/pubid/oiml/urn_parser.rb,
lib/pubid/oiml/identifiers.rb,
lib/pubid/oiml/urn_generator.rb,
lib/pubid/oiml/components/code.rb,
lib/pubid/oiml/identifiers/base.rb,
lib/pubid/oiml/identifiers/annex.rb,
lib/pubid/oiml/identifiers/guide.rb,
lib/pubid/oiml/single_identifier.rb,
lib/pubid/oiml/identifiers/document.rb,
lib/pubid/oiml/identifiers/amendment.rb,
lib/pubid/oiml/supplement_identifier.rb,
lib/pubid/oiml/identifiers/vocabulary.rb,
lib/pubid/oiml/identifiers/expert_report.rb,
lib/pubid/oiml/identifiers/recommendation.rb,
lib/pubid/oiml/identifiers/seminar_report.rb,
lib/pubid/oiml/identifiers/basic_publication.rb
Defined Under Namespace
Modules: Components, Identifiers Classes: Builder, Identifier, Parser, Renderer, SingleIdentifier, SupplementIdentifier, 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) ⇒ Object
Class Method Details
.all_typed_stages ⇒ Array<Pubid::Components::TypedStage>
Build typed stage index from identifier types
39 40 41 42 43 44 45 46 47 |
# File 'lib/pubid/oiml.rb', line 39 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
30 31 32 33 34 35 |
# File 'lib/pubid/oiml.rb', line 30 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
59 60 61 62 |
# File 'lib/pubid/oiml.rb', line 59 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
52 53 54 |
# File 'lib/pubid/oiml.rb', line 52 def self.locate_type(code) identifier_types.find { |t| t.type[:key].to_s == code.to_s } end |