Class: Pubid::Iho::UrnGenerator
- Inherits:
-
Object
- Object
- Pubid::Iho::UrnGenerator
- 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
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(identifier) ⇒ UrnGenerator
constructor
A new instance of UrnGenerator.
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
#identifier ⇒ Object (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
#generate ⇒ Object
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 |