Module: Pubid::Idf
- Defined in:
- lib/pubid/idf/identifier.rb,
lib/pubid/idf.rb,
lib/pubid/idf/parser.rb,
lib/pubid/idf/builder.rb,
lib/pubid/idf/renderer.rb,
lib/pubid/idf/urn_parser.rb,
lib/pubid/idf/identifiers.rb,
lib/pubid/idf/urn_generator.rb,
lib/pubid/idf/single_identifier.rb,
lib/pubid/idf/identifiers/amendment.rb,
lib/pubid/idf/supplement_identifier.rb,
lib/pubid/idf/identifiers/corrigendum.rb,
lib/pubid/idf/identifiers/reviewed_method.rb,
lib/pubid/idf/identifiers/international_standard.rb
Overview
Identifier that
Defined Under Namespace
Modules: 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.
-
.build_from_parse(hash) ⇒ Pubid::Idf::Identifier
Build an IDF identifier from a parse-tree hash (used by ISO joint-identifier parsing).
-
.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
47 48 49 50 51 52 53 54 55 |
# File 'lib/pubid/idf.rb', line 47 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 |
.build_from_parse(hash) ⇒ Pubid::Idf::Identifier
Build an IDF identifier from a parse-tree hash (used by ISO joint-identifier parsing). This is the public seam: callers should never reach into ‘Idf::Builder` directly.
28 29 30 |
# File 'lib/pubid/idf.rb', line 28 def self.build_from_parse(hash) Builder.new.build(hash) end |
.identifier_types ⇒ Array<Class>
Auto-discover all identifier types from the Identifiers namespace
38 39 40 41 42 43 |
# File 'lib/pubid/idf.rb', line 38 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
67 68 69 70 |
# File 'lib/pubid/idf.rb', line 67 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
60 61 62 |
# File 'lib/pubid/idf.rb', line 60 def self.locate_type(code) identifier_types.find { |t| t.type[:key].to_s == code.to_s } end |