Class: Pubid::Idf::UrnGenerator
- Inherits:
-
UrnGenerator::Base
- Object
- UrnGenerator::Base
- Pubid::Idf::UrnGenerator
- Defined in:
- lib/pubid/idf/urn_generator.rb
Instance Attribute Summary
Attributes inherited from UrnGenerator::Base
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_year
Constructor Details
This class inherits a constructor from Pubid::UrnGenerator::Base
Instance Method Details
#generate ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pubid/idf/urn_generator.rb', line 12 def generate parts = ["urn", "idf"] parts << urn_number if urn_number parts << urn_part if urn_part parts << urn_subpart if urn_subpart parts << urn_year if urn_year parts << urn_edition if urn_edition parts << urn_type if urn_type if identifier.publisher parts[1] = identifier.publisher.render(context: URN_CONTEXT) end if identifier.copublishers&.any? copubs = identifier.copublishers.map { |cp| cp.render(context: URN_CONTEXT) } parts[1] = "#{parts[1]}-#{copubs.join('-')}" end if identifier.languages&.any? parts << identifier.languages.map(&:code).join(",") end if identifier.is_a?(SupplementIdentifier) if identifier.typed_stage supp_type = identifier.typed_stage.type_code.to_s parts << supp_type if supp_type end if identifier.number parts << identifier.number.render(context: URN_CONTEXT) end end parts.join(":") end |
#urn_type ⇒ Object
6 7 8 9 10 |
# File 'lib/pubid/idf/urn_generator.rb', line 6 def urn_type return nil unless identifier.type identifier.type.abbr.to_s.downcase end |