Class: Pubid::Csa::Identifiers::Package

Inherits:
CompositeIdentifier show all
Defined in:
lib/pubid/csa/identifiers/package.rb

Overview

PackageIdentifier represents CSA standards sold as packages with additional materials (PDF, print, addenda, etc.)

Examples:

CSA Z662:23 PACKAGE INCLUDES: +1 (PDF & ESA)
CSA B149.1:20 PACKAGE (PDF + PRINT)
CSA C22.2 NO. 60601-1:15 PACKAGE WITH ADDENDUM

This is a composite pattern where:

- base_identifier is the core CSA standard (recursively parsed)
- package_materials describes what's included in the package
- Package portion is metadata, not a parseable identifier

Difference from BundledIdentifier:

- Package: Single base + materials metadata
- Bundled: Multiple identifiers consolidated together

Instance Attribute Summary

Attributes inherited from CompositeIdentifier

#base_identifier

Instance Method Summary collapse

Instance Method Details

#to_sObject



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
# File 'lib/pubid/csa/identifiers/package.rb', line 36

def to_s
  result = base_identifier.to_s

  # Add package materials if present
  if package_materials && !package_materials.empty?
    if materials_after_keyword
      # Format: {base} PACKAGE {materials}
      result += " PACKAGE"
      result += " #{package_materials}"
    elsif package_materials.match?(/\sPACKAGE\s*$/i)
      # Format: {base} {materials} PACKAGE
      # Check if materials already end with "Package" (to preserve exact capitalization)
      # Materials already include the Package suffix
      result += " #{package_materials}"
    else
      # Add Package suffix (use the package_keyword value)
      result += " #{package_materials}"
      result += " #{package_keyword}"
    end
  else
    # No materials, just add PACKAGE keyword
    result += " PACKAGE"
  end

  result
end