Class: Pubid::Jcgm::Identifier

Inherits:
Identifier
  • Object
show all
Defined in:
lib/pubid/jcgm/identifier.rb

Direct Known Subclasses

SingleIdentifier

Constant Summary collapse

TYPE_KEY_TO_KLASS =

Factory mirroring pubid 1.x’s ‘Pubid::Jcgm::Identifier.create` API. Dispatches `:guide` (default) → Guide, `:gum_guide` → GumGuide.

{
  guide:     "Guide",
  gum_guide: "GumGuide",
}.freeze

Class Method Summary collapse

Methods inherited from Identifier

#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_s, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.create(type: nil, **opts) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/pubid/jcgm/identifier.rb', line 17

def self.create(type: nil, **opts)
  klass = resolve_create_class(type)
  attrs = coerce_create_attrs(opts)
  ts = klass.const_defined?(:TYPED_STAGES) &&
       klass.const_get(:TYPED_STAGES).find do |t|
         t.stage_code&.to_sym == :published
       end
  attrs[:typed_stage] = ts if ts
  klass.new(**attrs)
end

.parse(string) ⇒ Object



6
7
8
# File 'lib/pubid/jcgm/identifier.rb', line 6

def self.parse(string)
  Pubid::Jcgm.parse(string)
end