Class: Pubid::Csa::CompositeIdentifier

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/pubid/csa/composite_identifier.rb

Overview

CompositeIdentifier is the base class for identifiers that contain collections of other identifiers or package materials.

Examples:

- PackageIdentifier: Base + package materials
- Future: BundleIdentifier refactor to use composite

This follows the Composite pattern where an identifier can contain other identifiers or additional metadata as a collection.

Direct Known Subclasses

Identifiers::Package

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#baseObject

The primary/base identifier Use attr_accessor since it can be any identifier object



19
20
21
# File 'lib/pubid/csa/composite_identifier.rb', line 19

def base
  @base
end

Instance Method Details

#rootObject

CSA composites are not Pubid::Identifier objects, so they do not inherit #root. They are their own origin for matching purposes.



38
39
40
# File 'lib/pubid/csa/composite_identifier.rb', line 38

def root
  self
end

#to_mr_stringObject

CSA composites serialise through to_s, so MR mirrors that with ., :., /-, then lowercased (issue #142).



28
29
30
# File 'lib/pubid/csa/composite_identifier.rb', line 28

def to_mr_string
  to_s.tr(" ", ".").tr(":", ".").tr("/", "-").downcase
end

#to_sObject

Subclasses MUST implement to_s to define how they render

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/pubid/csa/composite_identifier.rb', line 22

def to_s
  raise NotImplementedError, "Subclasses must implement to_s method"
end

#to_slugObject



32
33
34
# File 'lib/pubid/csa/composite_identifier.rb', line 32

def to_slug
  to_mr_string
end