Class: Pubid::Iala::UrnParser
- Inherits:
-
UrnParser::Base
- Object
- UrnParser::Base
- Pubid::Iala::UrnParser
- Defined in:
- lib/pubid/iala/urn_parser.rb
Overview
Parses IALA MRN URNs back into identifiers.
UrnGenerator emits:
urn:mrn:iala:pub:<type-lower><number>[:ed<edition>][:<lang-lower>]
Examples:
urn:mrn:iala:pub:s1070:ed2.0 → IALA S1070 Ed 2.0
urn:mrn:iala:pub:r1016:ed2.0:f → IALA R1016 Ed 2.0 (F)
urn:mrn:iala:pub:c0103-1 → IALA C0103-1
Constant Summary collapse
- PREFIX =
"urn:mrn:iala:pub:".freeze
Instance Method Summary collapse
Methods inherited from UrnParser::Base
Instance Method Details
#parse_urn(urn) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pubid/iala/urn_parser.rb', line 17 def parse_urn(urn) body = strip_namespace(urn) parts = split_parts(body) code = parts.fetch(0) edition = nil language = nil parts.drop(1).each do |seg| if seg.start_with?("ed") edition = seg.sub(/\Aed/, "") elsif seg.length == 1 && seg.match?(/\A[a-z]\z/i) language = seg.upcase end end text = "IALA #{code.upcase}" text += " Ed #{edition}" if edition text += " (#{language})" if language flavor_parse(text) end |