Class: Pubid::Iec::Identifiers::ConsolidatedIdentifier

Inherits:
Pubid::Iec::Identifier show all
Defined in:
lib/pubid/iec/identifiers/consolidated_identifier.rb

Overview

Consolidated Identifier Single Responsibility: Represents a consolidated publication containing multiple documents Example: “IEC 60529:1989+AMD1:1999” contains [IS, AMD] as separate identifier objects This is MODEL-DRIVEN: stores the actual identifiers, not just renders with +

Instance Method Summary collapse

Methods inherited from Pubid::Iec::Identifier

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, #to_urn, #urn_supplement_type, #urn_type_code

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Method Details

#base_documentObject

Get the base document (first identifier)



75
76
77
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 75

def base_document
  identifiers&.first
end

#codeObject



50
51
52
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 50

def code
  identifiers&.first&.code
end

#copublishersObject



46
47
48
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 46

def copublishers
  identifiers&.first&.copublishers
end

#dateObject



58
59
60
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 58

def date
  identifiers&.first&.date
end

#numberObject



54
55
56
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 54

def number
  identifiers&.first&.number
end

#publisherObject

Delegate common attributes to first identifier (base document)



42
43
44
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 42

def publisher
  identifiers&.first&.publisher
end

#stageObject



66
67
68
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 66

def stage
  identifiers&.first&.stage
end

#supplementsObject

Get all supplements (identifiers after first)



80
81
82
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 80

def supplements
  identifiers&.drop(1) || []
end

#to_s(lang: :en, lang_single: false, with_edition: false) ⇒ Object



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
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 14

def to_s(lang: :en, lang_single: false, with_edition: false)
  identifiers.map.with_index do |id, idx|
    if idx.zero?
      # First identifier renders normally
      id.to_s(lang: lang, lang_single: lang_single,
              with_edition: with_edition)
    elsif id.is_a?(Amendment)
      # Subsequent identifiers render with + prefix
      # For amendments, just show +AMDn:year part (or +AMDn if no date)
      if id.date&.year && !id.date.year.empty?
        "+AMD#{id.number}:#{id.date.year}"
      else
        "+AMD#{id.number}"
      end
    elsif id.is_a?(Corrigendum)
      if id.date&.year && !id.date.year.empty?
        "+COR#{id.number}:#{id.date.year}"
      else
        "+COR#{id.number}"
      end
    else
      "+#{id.to_s(lang: lang, lang_single: lang_single,
                  with_edition: with_edition)}"
    end
  end.join
end

#typeObject



62
63
64
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 62

def type
  :consolidated
end

#typed_stageObject



70
71
72
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 70

def typed_stage
  identifiers&.first&.typed_stage
end