Class: Pubid::Calconnect::UrnParser
- Inherits:
-
UrnParser::Base
- Object
- UrnParser::Base
- Pubid::Calconnect::UrnParser
- Defined in:
- lib/pubid/calconnect/urn_parser.rb
Overview
Parses CalConnect URNs back into identifiers.
UrnGenerator emits: urn:calconnect:
The date segment (year or full "YYYY-MM-DD") never contains a colon, so it is a single trailing part; the number precedes it, and an optional series precedes the number.
This positional pop assumes a dated URN (the form UrnGenerator emits for a full id). A partial (date-less) reference has no round-trippable URN — see UrnGenerator — so this parser is only guaranteed for URNs produced from a full id; a date-less URN misaligns the pops and will not parse.
Instance Method Summary collapse
Methods inherited from UrnParser::Base
Instance Method Details
#parse_urn(urn) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pubid/calconnect/urn_parser.rb', line 21 def parse_urn(urn) parts = split_parts(strip_namespace(urn)) date = parts.pop number = parts.pop series = parts.pop text = +"CC" text << "/#{series}" if series text << " #{number}:#{date}" flavor_parse(text) end |