Class: Pubid::Etsi::Identifiers::SupplementIdentifier

Inherits:
Base
  • Object
show all
Defined in:
lib/pubid/etsi/identifiers/supplement_identifier.rb

Overview

Base class for ETSI supplements (Amendment, Corrigendum)

Direct Known Subclasses

Amendment, Corrigendum

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



59
60
61
62
63
64
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 59

def ==(other)
  return false unless other.is_a?(SupplementIdentifier)
  return false unless other.class == self.class

  base == other.base && number == other.number
end

#base_hashObject

Include supplement notation in serialization



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 67

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

#codeObject



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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 31

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

#dateObject



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)



47
48
49
50
51
52
53
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 47

def find_actual_base(current_base)
  if current_base.is_a?(SupplementIdentifier)
    find_actual_base(current_base.base)
  else
    current_base
  end
end

#supplement_notationObject

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 55

def supplement_notation
  raise NotImplementedError
end

#typeObject

Inherit attributes from base



12
13
14
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 12

def type
  base.type
end

#versionObject



20
21
22
# File 'lib/pubid/etsi/identifiers/supplement_identifier.rb', line 20

def version
  base.version
end