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

Inherits:
SingleIdentifier show all
Includes:
CodeAttributes
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 included from CodeAttributes

#code_string, included

Methods inherited from SingleIdentifier

#date_sep_char, #exclude, #mr_languages, #mr_year

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_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

#mr_typeObject

CIE Standard distinguishes S-prefixed standards (CIE S 017) from plain (CIE 015), D-prefixed (CIE D001), and DIS-staged. The generic mr_type looks at typed_stage, which CIE doesn't use, so without this override the S/D/stage marker would be lost in MR.



74
75
76
77
78
79
80
# File 'lib/pubid/cie/identifiers/standard.rb', line 74

def mr_type
  return stage.downcase if stage
  return "d" if d_prefix
  return "s" if s_prefix

  nil
end

#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
61
62
63
64
65
66
67
68
# File 'lib/pubid/cie/identifiers/standard.rb', line 20

def to_s
  parts = ["CIE"]

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

  if d_prefix
    # D-series: the D is attached to the code (no space): CIE D001
    parts << "D#{code_string}"
  else
    # S prefix
    parts << "S" if s_prefix

    # Code
    parts << code_string if number
  end

  # 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

  # Bare slash-year (legacy, no language): CIE S 007/1998
  if year && style == "slash"
    result += "/#{year}"
    return result
  end

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

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

  result
end