Module: Pubid::Itu::Identifier
- Defined in:
- lib/pubid/itu/identifier.rb
Class Method Summary collapse
-
.create(type: nil, **kwargs) ⇒ Object
Factory mirroring v1’s Pubid::Itu::Identifier.create API.
- .create_special_publication(number:, series: "OB", date: nil, language: nil) ⇒ Object
- .parse(identifier) ⇒ Object
Class Method Details
.create(type: nil, **kwargs) ⇒ Object
Factory mirroring v1’s Pubid::Itu::Identifier.create API. The v1 form accepts a ‘type:` discriminator plus attribute kwargs; this v2 implementation supports the subset needed by metanorma-itu PR #497:
* type: :annex — builds Identifiers::Annex
* series: "OB" (with no type:) — builds Identifiers::SpecialPublication
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pubid/itu/identifier.rb', line 25 def self.create(type: nil, **kwargs) case type when :annex Identifiers::Annex.new(**kwargs) when nil if kwargs[:series].to_s == "OB" create_special_publication(**kwargs) else raise ArgumentError, "Identifier.create without :type requires series: 'OB'" end else raise ArgumentError, "Unsupported type for Identifier.create: #{type.inspect}" end end |
.create_special_publication(number:, series: "OB", date: nil, language: nil) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/pubid/itu/identifier.rb', line 42 def self.create_special_publication(number:, series: "OB", date: nil, language: nil) Identifiers::SpecialPublication.new( series: Components::Series.new(series: series.to_s), code: Components::Code.new(number: number.to_s), date: date, language: language&.to_s, ) end |