Class: Pubid::Plateau::UrnGenerator

Inherits:
UrnGenerator::Base show all
Defined in:
lib/pubid/plateau/urn_generator.rb

Instance Attribute Summary

Attributes inherited from UrnGenerator::Base

#identifier

Instance Method Summary collapse

Methods inherited from UrnGenerator::Base

#initialize, #maybe, #urn_edition, #urn_language, #urn_namespace, #urn_number, #urn_part, #urn_publisher, #urn_subpart, #urn_type, #urn_year

Constructor Details

This class inherits a constructor from Pubid::UrnGenerator::Base

Instance Method Details

#generateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pubid/plateau/urn_generator.rb', line 6

def generate
  parts = ["urn", "plateau"]

  if identifier.type_string
    type_str = identifier.type_string.to_s.downcase
    parts << case type_str
             when "technical report"
               "tr"
             when "annex"
               "an"
             else
               type_str
             end
  end

  parts << format("%02d", identifier.number) if identifier.number

  parts << format("%02d", identifier.annex) if identifier.annex

  parts.join(":")
end