Class: Pubid::Cie::Identifiers::Identical

Inherits:
SingleIdentifier show all
Defined in:
lib/pubid/cie/identifiers/identical.rb

Overview

Identical identifier for CIE Represents CIE identifiers with ISO reference Examples:

CIE S 006.1/1998 (ISO 16508:1999) - iteration with dot
CIE S 014-4/E2007 - part with dash + language
CIE S 008/E:2001 (ISO 8995-1:2002(E)) - language with colon year

Instance Method Summary collapse

Methods inherited from SingleIdentifier

#publisher

Methods inherited from Pubid::Cie::Identifier

parse

Instance Method Details

#to_sObject



20
21
22
23
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
57
58
59
60
# File 'lib/pubid/cie/identifiers/identical.rb', line 20

def to_s
  parts = ["CIE"]

  # S prefix
  parts << "S" if s_prefix

  # Code
  parts << code.to_s if code

  result = parts.join(" ")

  # Language + Year combined for slash formats before ISO reference
  if language && (language.format == "slash_colon" || (language.format == "slash" && year && date_separator != "slash"))
    # Render /E:YYYY or /EYYYY (language with year, no separate date separator)
    result += if language.format == "slash_colon"
                "/#{language.code}:#{year}" # /E:2001
              else
                "/#{language.code}#{year}" # /E2007 (no colon)
              end
  elsif language && language.format == "slash"
    # Language without year: /E
    result += "/#{language.code}"
  elsif year && date_separator == "slash"
    # Legacy slash-year format without language: /1998
    result += "/#{year}"
  elsif year
    # Standard date with separator (colon or dash)
    separator = date_separator == "colon" ? ":" : "-"
    result += "#{separator}#{year}"
  end

  # Language (parenthetical) after date
  if language && language.format != "slash" && language.format != "slash_colon"
    result += language.to_s
  end

  # ISO reference in parentheses
  result += " (ISO #{iso_reference})" if iso_reference

  result
end