Class: Pubid::Csa::WrapperIdentifier

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

Overview

WrapperIdentifier is the base class for all CSA identifiers that wrap other identifiers Examples:

- CanadianAdoptedIdentifier: CAN/{wrapped_identifier}
- CsaAdoptedIdentifier: CSA {ISO/IEC/CISPR identifier}

The wrapper pattern allows proper MODEL-DRIVEN architecture where adoptions are objects that contain other identifier objects, not string prefixes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#wrapped_identifierObject

The wrapped identifier (recursively parsed) Use attr_accessor since it can be any identifier object (CSA, ISO, IEC, etc.)



17
18
19
# File 'lib/pubid/csa/wrapper_identifier.rb', line 17

def wrapped_identifier
  @wrapped_identifier
end

Instance Method Details

#rootObject

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



43
44
45
# File 'lib/pubid/csa/wrapper_identifier.rb', line 43

def root
  self
end

#to_mr_stringObject

CSA wrappers serialise through to_s (their distinct shape is what makes them wrappers), so MR mirrors that with ., :., /-, then lowercased (issue #142).



33
34
35
# File 'lib/pubid/csa/wrapper_identifier.rb', line 33

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

#to_sObject

Subclasses MUST implement to_s

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/pubid/csa/wrapper_identifier.rb', line 26

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

#to_slugObject



37
38
39
# File 'lib/pubid/csa/wrapper_identifier.rb', line 37

def to_slug
  to_mr_string
end