Class: Pubid::Bsi::UrnGenerator
- Inherits:
-
UrnGenerator::Base
- Object
- UrnGenerator::Base
- Pubid::Bsi::UrnGenerator
- Defined in:
- lib/pubid/bsi/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_type, #urn_year
Constructor Details
This class inherits a constructor from Pubid::UrnGenerator::Base
Instance Method Details
#generate ⇒ Object
6 7 8 9 10 11 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/pubid/bsi/urn_generator.rb', line 6 def generate parts = ["urn", "bsi"] if identifier.publisher pub = identifier.publisher.to_s parts << pub.to_s.downcase else parts << "bs" end if identifier.prefix parts << identifier.prefix.to_s.downcase end if identifier.flex_prefix parts << identifier.flex_prefix.to_s.downcase end if identifier.number number = identifier.number.to_s if identifier.iteration && !identifier.iteration.empty? number += "[#{identifier.iteration}]" end parts << number end if identifier.part part = identifier.part.to_s parts << "-#{part}" end if identifier.subpart subpart = identifier.subpart.to_s parts << "-#{subpart}" end if identifier.second_number second = identifier.second_number.to_s parts << "/#{second}" end if identifier.date year = identifier.date.year parts << year.to_s elsif identifier.year parts << identifier.year.to_s end if identifier.month parts << format("%02d", identifier.month) end if identifier.edition parts << "v#{identifier.edition}" end if identifier.translation_lang parts << identifier.translation_lang.to_s.downcase elsif identifier.translation_upper parts << identifier.translation_upper.to_s.downcase end if identifier.type type = identifier.type&.abbr || identifier.type.to_s parts << type.to_s.downcase if type && type.to_s != "BS" end if identifier.typed_stage stage_code = identifier.typed_stage.stage_code if stage_code && stage_code != :published parts << "stage.#{stage_code}" end end parts.join(":") end |