Class: Pubid::Cie::Identifiers::Supplement

Inherits:
SupplementIdentifier show all
Defined in:
lib/pubid/cie/identifiers/supplement.rb

Overview

Supplement identifier for CIE (-SPN / -SPN.P notation). Wraps a nested base (the base Standard); the "-SPN" is inserted after the base number, so to_s renders from the base's parts. Examples: CIE 121-SP1:2009, CIE 198-SP1.4:2011, CIE DIS 025-SP1/E:2019

Instance Method Summary collapse

Methods inherited from SupplementIdentifier

#base_document, #drop_supplements, #supplement_number

Methods inherited from Pubid::Cie::Identifier

parse

Methods inherited from Identifier

apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, #exclude, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_languages, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Method Details

#supplement_typeObject

Uniform supplement interface (shared with Corrigendum).



17
18
19
# File 'lib/pubid/cie/identifiers/supplement.rb', line 17

def supplement_type
  :supplement
end

#supplement_yearObject



21
22
23
# File 'lib/pubid/cie/identifiers/supplement.rb', line 21

def supplement_year
  base&.year
end

#to_sObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pubid/cie/identifiers/supplement.rb', line 25

def to_s
  b = base
  parts = ["CIE"]
  parts << b.stage if b.respond_to?(:stage) && b.stage

  core = "#{b.number}-SP#{number}"
  core += ".#{part}" if part
  parts << core
  result = parts.join(" ")

  # Language with slash (before year), e.g. "/E"
  if b.language && b.language.format == "slash_colon"
    result += "/#{b.language.code}"
  end

  # Supplements always use the current (colon) style.
  result += ":#{b.year}" if b.year
  result
end