Module: Pubid::Itu::Identifier
- Defined in:
- lib/pubid/itu/identifier.rb
Constant Summary collapse
- TYPE_KEY_TO_KLASS =
Factory mirroring pubid 1.x’s ‘Pubid::Itu::Identifier.create` API. Dispatch on `:type`:
* nil → Recommendation (or SpecialPublication for series "OB") * :recommendation → Identifiers::Recommendation * :annex → Identifiers::Annex * :special_publication → Identifiers::SpecialPublicationComponent-typed kwargs are accepted as primitives and coerced:
* sector: "T" → Components::Sector.new(sector: "T") * series: "X" → Components::Series.new(series: "X") * number: "509" → Components::Code.new(number: "509") * year: "2020" → Pubid::Components::Date.new(year: "2020") { recommendation: "Recommendation", annex: "Annex", special_publication: "SpecialPublication", }.freeze
Class Method Summary collapse
- .create(type: nil, **kwargs) ⇒ Object
-
.create_special_publication(number:, series: "OB", date: nil, language: nil) ⇒ Object
Backward-compat helper retained for the OB-series shortcut.
- .parse(identifier) ⇒ Object
Class Method Details
.create(type: nil, **kwargs) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/pubid/itu/identifier.rb', line 38 def self.create(type: nil, **kwargs) # Backward-compat: nil type + series "OB" → SpecialPublication. if type.nil? && kwargs[:series].to_s == "OB" return create_special_publication(**kwargs) end klass = resolve_create_class(type) klass.new(**coerce_create_attrs(kwargs, klass: klass)) end |
.create_special_publication(number:, series: "OB", date: nil, language: nil) ⇒ Object
Backward-compat helper retained for the OB-series shortcut.
58 59 60 61 62 63 64 65 66 |
# File 'lib/pubid/itu/identifier.rb', line 58 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 |