Class: Pubid::CenCenelec::Identifiers::ConsolidatedIdentifier

Inherits:
Base
  • Object
show all
Defined in:
lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb

Overview

Consolidated Identifier - contains base document plus supplements Example: “EN 196-3:2005+A1:2008” = [EN 196-3:2005, Amendment(base + params)]

Instance Method Summary collapse

Methods inherited from Base

#==

Methods inherited from 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

#numberObject



43
44
45
# File 'lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb', line 43

def number
  identifiers&.first&.number
end

#partsObject



51
52
53
# File 'lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb', line 51

def parts
  identifiers&.first&.parts
end

#publisherObject

Delegate to first identifier (base document)



39
40
41
# File 'lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb', line 39

def publisher
  identifiers&.first&.publisher
end

#to_sObject



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

def to_s
  identifiers.map.with_index do |id, idx|
    if idx.zero?
      # First identifier renders normally
      id.to_s
    elsif id.is_a?(Amendment)
      # Supplements render with "+" prefix (bundled/consolidated format)
      result = "+A#{id.amendment_number}"
      result += ":#{id.amendment_year}" if id.amendment_year
      result
    # Only render the amendment portion, not the full id.to_s
    elsif id.is_a?(Corrigendum)
      # Only render the corrigendum portion
      result = "+AC"
      result += id.corrigendum_number if id.corrigendum_number && !id.corrigendum_number.empty?
      if id.corrigendum_year
        result += ":#{id.corrigendum_year}"
        result += "-#{id.corrigendum_month}" if id.corrigendum_month && !id.corrigendum_month.empty?
      end
      result
    else
      # Other identifiers (should not happen in typical bundles) render with +
      "+#{id}"
    end
  end.compact.join
end

#typeObject



55
56
57
# File 'lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb', line 55

def type
  identifiers&.first&.type
end

#yearObject



47
48
49
# File 'lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb', line 47

def year
  identifiers&.first&.year
end