Module: Pubid::Ieee::Identifier
- Defined in:
- lib/pubid/ieee/identifier.rb
Class Method Summary collapse
-
.create(type: nil, **opts) ⇒ Object
Factory mirroring pubid 1.x’s ‘Pubid::Ieee::Identifier.create` API.
- .parse(input) ⇒ Object
Class Method Details
.create(type: nil, **opts) ⇒ Object
Factory mirroring pubid 1.x’s ‘Pubid::Ieee::Identifier.create` API. Dispatches via Scheme.locate_identifier_klass_by_type_code. Default subclass (no `type:`) is Identifiers::Standard — the canonical class produced by parsing typical IEEE identifiers.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pubid/ieee/identifier.rb', line 15 def create(type: nil, **opts) klass = type ? Scheme.locate_identifier_klass_by_type_code(type) : Identifiers::Standard attrs = coerce_create_attrs(opts) # ProjectDraftIdentifier renders the "P" prefix from typed_stage, # not from `type`. Set both so the output matches a parsed form. if klass == Identifiers::ProjectDraftIdentifier attrs[:type] = "P" attrs[:typed_stage] ||= Scheme.locate_typed_stage_by_abbr("P") end klass.new(**attrs) end |
.parse(input) ⇒ Object
7 8 9 |
# File 'lib/pubid/ieee/identifier.rb', line 7 def parse(input) Identifiers::Base.parse(input) end |