Class: Pubid::Iso::BundledIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Pubid::Identifier
- Identifier
- Pubid::Iso::BundledIdentifier
- Defined in:
- lib/pubid/iso/bundled_identifier.rb
Overview
Identifier that represents a bundled identifier with base document and supplements E.g., “ISO/IEC DIR 1 + IEC SUP:2016-05” or “ISO/IEC DIR 1:2022 + IEC SUP:2022”
Constant Summary
Constants inherited from Identifier
Instance Method Summary collapse
- #copublishers ⇒ Object
- #date ⇒ Object
- #number ⇒ Object
- #part ⇒ Object
-
#publisher ⇒ Object
Delegate key attributes to base_document for easier access in tests.
- #to_s(lang: :en, lang_single: false, with_edition: false, format: nil, stage_format_long: nil, with_date: nil) ⇒ Object
-
#to_urn ⇒ Object
Generate URN for bundled identifier Format: urn:iso:doc:base_urn:supplement_urn_parts Example: urn:iso:doc:iso-iec:dir:1:2022:iec:sup:2022.
- #typed_stage ⇒ Object
Methods inherited from Identifier
build_base_identifier, build_type_map, create, locate_create_typed_stage, locate_klass_by_type_or_short, parse, retype_stage_for_class
Methods inherited from Pubid::Identifier
#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_supplement_s, #urn_supplement_type, #urn_type_code, #year
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Method Details
#copublishers ⇒ Object
34 35 36 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 34 def copublishers base_document&.copublishers end |
#date ⇒ Object
26 27 28 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 26 def date base_document&.date end |
#number ⇒ Object
18 19 20 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 18 def number base_document&.number end |
#part ⇒ Object
22 23 24 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 22 def part base_document&.part end |
#publisher ⇒ Object
Delegate key attributes to base_document for easier access in tests
14 15 16 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 14 def publisher base_document&.publisher end |
#to_s(lang: :en, lang_single: false, with_edition: false, format: nil, stage_format_long: nil, with_date: nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 38 def to_s(lang: :en, lang_single: false, with_edition: false, format: nil, stage_format_long: nil, with_date: nil) parts = [base_document.to_s(lang: lang, lang_single: lang_single, with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date)] # Add each supplement with "+" separator supplements.each do |supplement| supplement_str = supplement.to_supplement_s(lang: lang, lang_single: lang_single, with_edition: with_edition, format: format, stage_format_long: stage_format_long, with_date: with_date) parts << "+ #{supplement_str}" end parts.join(" ") end |
#to_urn ⇒ Object
Generate URN for bundled identifier Format: urn:iso:doc:base_urn:supplement_urn_parts Example: urn:iso:doc:iso-iec:dir:1:2022:iec:sup:2022
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 82 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 56 def to_urn # Start with base document URN (remove "urn:" prefix if exists) base_urn = base_document.to_urn base_parts = base_urn.split(":").drop(1) # Drop "urn" prefix # Build URN parts starting with "urn" urn_parts = ["urn"] # Add base URN parts urn_parts.concat(base_parts) # Add each supplement's URN contribution supplements.each do |supplement| sup_urn = supplement.to_urn if supplement.is_a?(Identifiers::DirectivesSupplement) # DirectivesSupplement has special URN format # Extract parts after "urn:iso:doc:" else # For other supplement types, add their URN parts # Extract relevant parts and add them end sup_parts = sup_urn.split(":").drop(3) urn_parts.concat(sup_parts) end urn_parts.join(":") end |
#typed_stage ⇒ Object
30 31 32 |
# File 'lib/pubid/iso/bundled_identifier.rb', line 30 def typed_stage base_document&.typed_stage end |