Class: Pubid::Iso::BundledIdentifier

Inherits:
Identifier show all
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

Identifier::ISO_TYPE_MAP

Instance Method Summary collapse

Methods inherited from Identifier

build_type_map, parse

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

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Method Details

#copublishersObject



34
35
36
# File 'lib/pubid/iso/bundled_identifier.rb', line 34

def copublishers
  base_document&.copublishers
end

#dateObject



26
27
28
# File 'lib/pubid/iso/bundled_identifier.rb', line 26

def date
  base_document&.date
end

#numberObject



18
19
20
# File 'lib/pubid/iso/bundled_identifier.rb', line 18

def number
  base_document&.number
end

#partObject



22
23
24
# File 'lib/pubid/iso/bundled_identifier.rb', line 22

def part
  base_document&.part
end

#publisherObject

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_urnObject

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_stageObject



30
31
32
# File 'lib/pubid/iso/bundled_identifier.rb', line 30

def typed_stage
  base_document&.typed_stage
end