Class: Pubid::Calconnect::UrnGenerator
- Inherits:
-
UrnGenerator::Base
- Object
- UrnGenerator::Base
- Pubid::Calconnect::UrnGenerator
- Defined in:
- lib/pubid/calconnect/urn_generator.rb
Overview
Emits CalConnect URNs of the form
urn:calconnect:
The series keeps its printed case (JIS keeps its code case likewise) so a URN reconstructs the human form losslessly — mirror in urn_parser.rb.
NOTE: a partial (date-less) reference has NO round-trippable URN form.
Both series and date are optional, and UrnParser reads the trailing
segments positionally, so a date-less URN like "urn:calconnect:11001"
(or "urn:calconnect:DIR:10006") is ambiguous with a series-less dated URN
and does not parse back. Partial refs are matched by pubid #exclude,
not by URN, so this generator simply omits the missing segment rather
than emitting an empty ":" — callers must not rely on URN round-trip for
a partial id.
Instance Attribute Summary
Attributes inherited from UrnGenerator::Base
Instance Method Summary collapse
Methods inherited from UrnGenerator::Base
#initialize, #maybe, #urn_edition, #urn_language, #urn_namespace, #urn_number, #urn_part, #urn_publisher, #urn_subpart, #urn_type, #urn_year
Constructor Details
This class inherits a constructor from Pubid::UrnGenerator::Base
Instance Method Details
#generate ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/pubid/calconnect/urn_generator.rb', line 22 def generate # series and date_string are nil for a series-less or partial # (date-less) id; compact drops them so no empty ":" segment appears. parts = [ "urn", "calconnect", identifier.series, identifier.number.to_s, identifier.date_string ] parts.compact.join(":") end |