Class: Pubid::Iala::UrnGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/pubid/iala/urn_generator.rb

Overview

Generates URN strings for IALA identifiers using the Maritime Resource Name (MRN) namespace that IALA prints on its cover pages.

Format: urn:mrn:iala:pub:[:ed][:] Example: urn:mrn:iala:pub:s1070:ed2.0 urn:mrn:iala:pub:r1016:ed2.0:f

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ UrnGenerator

Returns a new instance of UrnGenerator.



14
15
16
# File 'lib/pubid/iala/urn_generator.rb', line 14

def initialize(identifier)
  @identifier = identifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



12
13
14
# File 'lib/pubid/iala/urn_generator.rb', line 12

def identifier
  @identifier
end

Instance Method Details

#generateObject



18
19
20
21
22
23
# File 'lib/pubid/iala/urn_generator.rb', line 18

def generate
  parts = ["urn:mrn:iala:pub", code_segment]
  parts << "ed#{identifier.edition}" if identifier.edition
  parts << identifier.language.downcase if identifier.language
  parts.join(":")
end