Class: Pubid::Cie::SingleIdentifier

Inherits:
Identifier show all
Defined in:
lib/pubid/cie/single_identifier.rb

Overview

Base class for single CIE identifiers (standards, conferences, etc.) Single Responsibility: Provide common attributes for base documents

Single identifiers are base documents that can exist independently, as opposed to supplement identifiers (amendments, corrigenda) which modify a base identifier.

Classes inheriting from SingleIdentifier:

  • Standard (common CIE publications)
  • Conference (conference proceedings)
  • Bundle (bundles of multiple identifiers)
  • JointPublished (co-published with ISO/IEC)
  • DualPublished (dual published with IEC)
  • Identical (identical to ISO publications)
  • TutorialBundle (tutorial bundles)

Instance Method Summary collapse

Methods inherited from Identifier

parse

Methods inherited from Identifier

apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_type, #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_s, #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

#date_sep_charObject

The number<->year separator character, derived from style (the sole separator field; there is no date_separator attribute):

current -> ":"   legacy -> "-"   slash -> "/"


30
31
32
# File 'lib/pubid/cie/single_identifier.rb', line 30

def date_sep_char
  { "legacy" => "-", "slash" => "/" }.fetch(style, ":")
end

#exclude(*args) ⇒ Object

Partial-reference matching: CIE keeps the publication year in its own year string attribute (the separator lives in style), not a Date component, so the base's :year->:date remap would nil the unused inherited date and leave year intact. Call super (preserving the nested-identifier recursion), then nil year directly so a year-less CIE ref is a year wildcard under matches?(ignore: [:year]).

Known limit: style (which also encodes the era: current<->colon, legacy<->dash) is intentionally NOT wildcarded, so bare CIE 015 (always current) matches a colon-dated full but not a legacy dash-dated (pre-2001) one. Partial-ref scope targets modern colon forms.



45
46
47
48
49
# File 'lib/pubid/cie/single_identifier.rb', line 45

def exclude(*args)
  result = super
  result.year = nil if args.include?(:year) || args.include?(:date)
  result
end

#mr_languagesObject



61
62
63
64
65
66
# File 'lib/pubid/cie/single_identifier.rb', line 61

def mr_languages
  return nil unless respond_to?(:language) && language

  # Lowercase + filename-safe: drop the leading `/` (path-unsafe).
  language.code.to_s.downcase
end

#mr_yearObject

CIE stores its publication year in its own year string attribute (not a Components::Date), and uses a single-Language component with multiple formats. Override the lossless MR template so CIE S 017/E:2011 round-trips as CIE.S.017.E.2011 rather than losing the type letter, language, and year (issue #142). Subclasses add the s_prefix and language attributes that this template reads.



57
58
59
# File 'lib/pubid/cie/single_identifier.rb', line 57

def mr_year
  year&.to_s
end