Class: Pubid::Iec::Identifiers::ConsolidatedIdentifier

Inherits:
Pubid::Iec::Identifier show all
Includes:
DelegatedFieldSuppression
Defined in:
lib/pubid/iec/identifiers/consolidated_identifier.rb

Overview

Consolidated Identifier Single Responsibility: Represents a consolidated publication containing multiple documents Example: “IEC 60529:1989+AMD1:1999” contains [IS, AMD] as separate identifier objects This is MODEL-DRIVEN: stores the actual identifiers, not just renders with +

Constant Summary

Constants inherited from Pubid::Iec::Identifier

Pubid::Iec::Identifier::IEC_TYPE_MAP

Instance Method Summary collapse

Methods included from DelegatedFieldSuppression

#copublishers_to_kv, #number_to_kv, #part_to_kv, #publisher_to_kv, #stage_iteration_to_kv, #stage_to_kv, #subpart_to_kv, #year_to_kv

Methods inherited from Pubid::Iec::Identifier

#all_parts_from_kv, #all_parts_to_kv, #build_code, build_type_map, #copublishers_from_kv, #copublishers_to_kv, default_publisher, #emit_code, from_hash, #number_from_kv, #number_to_kv, parse, #part_from_kv, #part_to_kv, published_typed_stage, #publisher_from_kv, #publisher_to_kv, #stage_from_kv, #stage_iteration_from_kv, #stage_iteration_to_kv, #stage_to_kv, #subpart_from_kv, #subpart_to_kv, #type, #year_from_kv, #year_to_kv

Methods inherited from Pubid::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, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Method Details

#base_documentObject

Get the base document (first identifier)



72
73
74
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 72

def base_document
  identifiers&.first
end

#codeObject



51
52
53
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 51

def code
  identifiers&.first&.code
end

#copublishersObject



47
48
49
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 47

def copublishers
  identifiers&.first&.copublishers
end

#dateObject



59
60
61
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 59

def date
  identifiers&.first&.date
end

#identifiers_from_kv(model, value) ⇒ Object



32
33
34
35
36
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 32

def identifiers_from_kv(model, value)
  model.identifiers = Array(value).map do |h|
    ::Pubid::Iec::Identifier.from_hash(h)
  end
end

#identifiers_to_kv(model, doc) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 24

def identifiers_to_kv(model, doc)
  return unless model.identifiers&.any?

  doc.add_child(Lutaml::KeyValue::DataModel::Element.new(
                  "identifiers", model.identifiers.map(&:to_hash)
                ))
end

#numberObject



55
56
57
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 55

def number
  identifiers&.first&.number
end

#publisherObject

Delegate common attributes to first identifier (base document)



43
44
45
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 43

def publisher
  identifiers&.first&.publisher
end

#stageObject



63
64
65
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 63

def stage
  identifiers&.first&.stage
end

#supplementsObject

Get all supplements (identifiers after first)



77
78
79
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 77

def supplements
  identifiers&.drop(1) || []
end

#to_s(**opts) ⇒ Object



38
39
40
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 38

def to_s(**opts)
  render(format: :human, **opts)
end

#typed_stageObject



67
68
69
# File 'lib/pubid/iec/identifiers/consolidated_identifier.rb', line 67

def typed_stage
  identifiers&.first&.typed_stage
end