Class: Pubid::Iho::UrnGenerator

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

Overview

Generates URN strings for IHO identifiers.

Format: urn:iho:type-letter-lowercase:code[:part.part][:annex.annex][:suppl.supplement][:version] Example: urn:iho:s:44:5.0.0 for “IHO S-44 5.0.0”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ UrnGenerator

Returns a new instance of UrnGenerator.



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

def initialize(identifier)
  @identifier = identifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



10
11
12
# File 'lib/pubid/iho/urn_generator.rb', line 10

def identifier
  @identifier
end

Instance Method Details

#generateObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pubid/iho/urn_generator.rb', line 16

def generate
  parts = ["urn", "iho"]
  parts << identifier.type[:short].to_s.downcase
  parts << identifier.code.to_s
  parts << "ap.#{identifier.appendix}"     if identifier.appendix
  parts << "part.#{identifier.part}"       if identifier.part
  parts << "annex.#{identifier.annex}"     if identifier.annex
  parts << "suppl.#{identifier.supplement}" if identifier.supplement
  parts << identifier.version.to_s if identifier.version
  parts.join(":")
end