Class: Pubid::Etsi::Identifiers::SupplementIdentifier
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Identifier
- Base
- Pubid::Etsi::Identifiers::SupplementIdentifier
- Defined in:
- lib/pubid/etsi/identifiers/supplement_identifier.rb
Overview
Base class for ETSI supplements (Amendment, Corrigendum)
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#base_hash ⇒ Object
Include supplement notation in serialization.
- #code ⇒ Object
-
#collect_supplement_notations(current_supplement, notations) ⇒ Object
Recursively collect supplement notations from the supplement chain.
- #date ⇒ Object
-
#find_actual_base(current_base) ⇒ Object
Find the actual base ETSI standard (not supplements).
- #supplement_notation ⇒ Object
-
#to_s ⇒ Object
Render as: ETSI TYPE CODE/SUPPLEMENTS VERSION (DATE) When multiple supplements are present, they appear in order: /A1/C1.
-
#type ⇒ Object
Inherit attributes from base.
- #version ⇒ Object
Methods inherited from Base
Methods inherited from Identifier
#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Method Details
#==(other) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 69 def ==(other) return false unless other.is_a?(SupplementIdentifier) return false unless other.class == self.class base == other.base && number == other.number end |
#base_hash ⇒ Object
Include supplement notation in serialization
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 77 def base_hash hash = super # ETSI supplements need the type (e.g., "ETS", "TR") from the base document if base.class.attributes.key?(:type) && base.type hash[:type] = base.type end hash[:supplement_notation] = supplement_notation hash[:supplement_type] = self.class.name.split("::").last.downcase hash end |
#code ⇒ Object
16 17 18 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 16 def code base.code end |
#collect_supplement_notations(current_supplement, notations) ⇒ Object
Recursively collect supplement notations from the supplement chain
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 41 def collect_supplement_notations(current_supplement, notations) if current_supplement.is_a?(SupplementIdentifier) # Add this supplement's notation at the beginning (because supplements wrap from outside in) notations.unshift("/#{current_supplement.supplement_notation}") # Continue collecting from the base if it's also a supplement if current_supplement.base.is_a?(SupplementIdentifier) collect_supplement_notations(current_supplement.base, notations) else notations end else notations end end |
#date ⇒ Object
24 25 26 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 24 def date base.date end |
#find_actual_base(current_base) ⇒ Object
Find the actual base ETSI standard (not supplements)
57 58 59 60 61 62 63 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 57 def find_actual_base(current_base) if current_base.is_a?(SupplementIdentifier) find_actual_base(current_base.base) else current_base end end |
#supplement_notation ⇒ Object
65 66 67 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 65 def supplement_notation raise NotImplementedError end |
#to_s ⇒ Object
Render as: ETSI TYPE CODE/SUPPLEMENTS VERSION (DATE) When multiple supplements are present, they appear in order: /A1/C1
30 31 32 33 34 35 36 37 38 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 30 def to_s supplement_notations = collect_supplement_notations(self, []) # Get the actual base ETSI standard (not supplements) actual_base = find_actual_base(base) code_with_supplements = "#{actual_base.code}#{supplement_notations.join}" "#{actual_base.publisher} #{actual_base.type} #{code_with_supplements} #{actual_base.version} (#{actual_base.date.year}-#{actual_base.date.month.to_s.rjust( 2, '0' )})" end |
#type ⇒ Object
Inherit attributes from base
12 13 14 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 12 def type base.type end |
#version ⇒ Object
20 21 22 |
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 20 def version base.version end |