Class: Pubid::Bsi::Identifiers::NationalAnnex

Inherits:
SingleIdentifier show all
Defined in:
lib/pubid/bsi/identifiers/national_annex.rb

Overview

National Annex (NA) identifier Can have own supplements: “NA+A1:2012 to BASE”

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    code: :pubna,
    stage_code: :published,
    type_code: :na,
    abbr: ["NA"],
    name: "National Annex",
    harmonized_stages: %w[60.00 60.60],
  ),
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SingleIdentifier

#<=>, #publisher

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

Class Method Details

.typeObject



23
24
25
# File 'lib/pubid/bsi/identifiers/national_annex.rb', line 23

def self.type
  { key: :na, title: "National Annex", short: "NA" }
end

Instance Method Details

#dateObject



32
33
34
# File 'lib/pubid/bsi/identifiers/national_annex.rb', line 32

def date
  base_doc&.date || super
end

#numberObject

Delegation methods to access wrapped base_doc attributes



28
29
30
# File 'lib/pubid/bsi/identifiers/national_annex.rb', line 28

def number
  base_doc&.number || super
end

#partObject



36
37
38
# File 'lib/pubid/bsi/identifiers/national_annex.rb', line 36

def part
  base_doc&.part || super
end

#subpartObject



40
41
42
# File 'lib/pubid/bsi/identifiers/national_annex.rb', line 40

def subpart
  base_doc&.subpart || super
end

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



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
# File 'lib/pubid/bsi/identifiers/national_annex.rb', line 44

def to_s(lang: :en, lang_single: false)
  result = "NA"

  # Add NA supplements if present
  if na_supplements&.any?
    na_supplements.each do |supp|
      if supp.is_a?(Amendment)
        result += "+A#{supp.amendment_number}:#{supp.amendment_year}"
      elsif supp.is_a?(Corrigendum)
        result += "+C#{supp.corrigendum_number}:#{supp.corrigendum_year}"
      end
    end
  end

  result += " to "

  # Render the base identifier (what this NA is for)
  result += if base_doc
              base_doc.to_s
            else
              # Fallback to parent rendering
              super
            end

  result
end