Class: Pubid::Bsi::Identifiers::AddendumDocument

Inherits:
Base
  • Object
show all
Defined in:
lib/pubid/bsi/identifiers/addendum_document.rb

Overview

Addendum Document Identifier Contains a base identifier plus addendum parameters Supports various formats: “BS 1501-2 Addendum No. 1:1973” “BS 1902-2.3:Addendum No. 1:1976” “BS 2000-0:Addendum 1:1983” “BS 6034:1981:Addendum No. 1:1986”

Instance Method Summary collapse

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

#publisherObject



58
59
60
# File 'lib/pubid/bsi/identifiers/addendum_document.rb', line 58

def publisher
  base_identifier&.publisher
end

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

Separator before Addendum (“:” or “ ”)



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pubid/bsi/identifiers/addendum_document.rb', line 24

def to_s(lang: :en, lang_single: false)
  result = base_identifier.to_s(lang: lang, lang_single: lang_single)

  # Determine separator - if separator is explicitly ":", use it
  # Otherwise if base has year and doesn't already have double colon, use space
  base_has_year = base_identifier.to_s =~ /:(\d{4})$/

  sep = if separator == ":"
          ":"
        elsif base_has_year && base_identifier.to_s !~ /:\d{4}:/
          " "
        else
          separator
        end

  # Format: "BASE:Addendum No. N:YEAR" or "BASE Addendum No. N:YEAR" or "BASE:Addendum N:YEAR"
  result += sep
  result += "Addendum"

  # Add space after "Addendum" if there's a type prefix (like "No.")
  if addendum_type.empty?
    # No type prefix, but still need space before number
  else
    result += " #{addendum_type}"
  end
  result += " "
  result += " "

  result += addendum_number.to_s
  result += ":#{addendum_year}" if addendum_year

  result
end