Class: Pubid::Bsi::Identifiers::ExplanatorySupplement

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

Overview

ExplanatorySupplement represents BSI explanatory supplement documents Format: BS number-part:Explanatory Supplement:year

Examples:

BS 5655-1:Explanatory Supplement:1981

Constant Summary collapse

TYPED_STAGES =

TYPED_STAGES for explanatory supplement (published by default)

[
  Pubid::Components::TypedStage.new(
    code: :pubexplanatorysupplement,
    stage_code: :published,
    type_code: :explanatory_supplement,
    abbr: ["BS"],
    name: "Explanatory Supplement",
    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



24
25
26
27
28
29
30
# File 'lib/pubid/bsi/identifiers/explanatory_supplement.rb', line 24

def self.type
  {
    key: :explanatory_supplement,
    title: "Explanatory Supplement",
    short: "BS",
  }
end

Instance Method Details

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



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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/pubid/bsi/identifiers/explanatory_supplement.rb', line 32

def to_s(lang: :en, lang_single: false)
  # Explanatory Supplement format:
  # BS {number}-{part}:Explanatory Supplement:{year}
  parts = []
  parts << "BS"

  # Number with part/subpart
  if number
    number_str = if number.is_a?(Components::Code)
                   number.value.to_s
                 else
                   number.to_s
                 end

    # Part and subpart
    if part
      part_val = if part.is_a?(Components::Code)
                   part.value
                 else
                   part
                 end
      number_str += "-#{part_val}"
    end
    if subpart
      subpart_val = if supart.is_a?(Components::Code)
                      subpart.value
                    else
                      subpart
                    end
      number_str += "-#{subpart_val}"
    end

    parts << number_str
  end

  result = parts.join(" ")

  # Date
  if date
    year_val = date.is_a?(Components::Date) ? date.year : date.to_i
    result += ":Explanatory Supplement:#{year_val}"
    # Month if present
    result += "-#{format('%02d', month)}" if month
  end

  result
end