Class: Pubid::Easc::UrnParser
- Inherits:
-
UrnParser::Base
- Object
- UrnParser::Base
- Pubid::Easc::UrnParser
- Defined in:
- lib/pubid/easc/urn_parser.rb
Overview
Parses EASC URNs back into identifiers.
UrnGenerator emits:
urn:easc:<series>[:<variant>]:<number>[:<year>]
Examples:
urn:easc:pmg:3:2025 → ПМГ 3-2025
urn:easc:pmg:v:31:2001 → ПМГ В 31-2001
urn:easc:rmg:151:2025 → РМГ 151-2025
Constant Summary collapse
- PREFIX =
"urn:easc:".freeze
- VARIANT_SEGMENT =
/\Av\z/i.freeze
Instance Method Summary collapse
Methods inherited from UrnParser::Base
Instance Method Details
#parse_urn(urn) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pubid/easc/urn_parser.rb', line 18 def parse_urn(urn) body = strip_namespace(urn) parts = split_parts(body) series = parts.fetch(0) rest = parts.drop(1) variant = nil if rest.first&.match?(VARIANT_SEGMENT) variant = "V" rest = rest.drop(1) end number = rest[0] year = rest[1] klass = Easc.identifier_klass_for_series(series) || Identifier klass.new(series: series.upcase, variant: variant, number: number, year: year) end |