Class: Pubid::Csa::WrapperIdentifier
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Csa::WrapperIdentifier
- 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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#wrapped_identifier ⇒ Object
The wrapped identifier (recursively parsed) Use attr_accessor since it can be any identifier object (CSA, ISO, IEC, etc.).
Instance Method Summary collapse
-
#root ⇒ Object
CSA wrappers are not Pubid::Identifier objects, so they do not inherit #root.
-
#to_mr_string ⇒ Object
CSA wrappers serialise through
to_s(their distinct shape is what makes them wrappers), so MR mirrors that with→.,:→.,/→-, then lowercased (issue #142). -
#to_s ⇒ Object
Subclasses MUST implement to_s.
- #to_slug ⇒ Object
Instance Attribute Details
#wrapped_identifier ⇒ Object
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
#root ⇒ Object
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_string ⇒ Object
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_s ⇒ Object
Subclasses MUST implement to_s
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_slug ⇒ Object
37 38 39 |
# File 'lib/pubid/csa/wrapper_identifier.rb', line 37 def to_slug to_mr_string end |