Class: Pubid::Cie::Identifiers::Standard

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

Overview

Standard identifier for CIE Handles both legacy (pre-2001) and current (2001+) styles

Instance Method Summary collapse

Methods inherited from SingleIdentifier

#publisher

Methods inherited from Pubid::Cie::Identifier

parse

Instance Method Details

#to_sObject



16
17
18
19
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
# File 'lib/pubid/cie/identifiers/standard.rb', line 16

def to_s
  parts = ["CIE"]

  # Stage (DIS/DS) before code if present
  parts << stage if stage

  # S prefix
  parts << "S" if s_prefix

  # Code
  parts << code.to_s if code

  # Build initial result from parts
  result = parts.join(" ")

  # Language (slash format without year) - appended before date
  if language && language.format == "slash"
    result += "/#{language.code}"
  end

  # Language (slash_colon format with year) - language/colon/year as unit
  if language && language.format == "slash_colon"
    result += "/#{language.code}:#{year}"
    return result # Year already added
  end

  # Date with separator (for non-slash-colon formats)
  if year
    separator = date_separator == "colon" ? ":" : "-"
    result += "#{separator}#{year}"
  end

  # Language (parenthetical formats) - comes after date
  if language && !["slash", "slash_colon"].include?(language.format)
    result += language.to_s
  end

  result
end