Class: Pubid::Components::Code
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Components::Code
- Defined in:
- lib/pubid/components/code.rb
Overview
Document code/number component.
Holds the structured fields that recur across flavors: the main value (always present), plus optional prefix (series/type designator), part, subpart, and free-form parts. Subclasses own their composition rules — flavor-specific separators and orderings live in the subclass #to_s / #render override.
Direct Known Subclasses
Bsi::Components::Code, Iec::Components::Code, Iso::Components::Code, Nist::Components::Code
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
rubocop:disable Metrics/AbcSize.
- #hash ⇒ Object
-
#render(context: nil) ⇒ Object
Format-aware render seam.
- #to_s ⇒ Object
Instance Method Details
#eql?(other) ⇒ Boolean
rubocop:disable Metrics/AbcSize
35 36 37 38 39 40 41 42 43 |
# File 'lib/pubid/components/code.rb', line 35 def eql?(other) return false unless other.is_a?(self.class) value == other.value && prefix == other.prefix && part == other.part && subpart == other.subpart && parts == other.parts end |
#hash ⇒ Object
30 31 32 |
# File 'lib/pubid/components/code.rb', line 30 def hash [value, prefix, part, subpart, parts].hash end |
#render(context: nil) ⇒ Object
Format-aware render seam. Default returns the bare value; subclasses override to compose flavor-specific shapes (e.g. ISO joins parts with “-”, NIST joins subpart with “.”).
26 27 28 |
# File 'lib/pubid/components/code.rb', line 26 def render(context: nil) value.to_s end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/pubid/components/code.rb', line 19 def to_s value.to_s end |