Class: Pubid::Iec::Identifiers::FragmentIdentifier

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

Overview

Fragment Identifier Single Responsibility: Represents a specific fragment/part within an Amendment or Corrigendum Example: “IEC 60050-191/AMD2/FRAG2 ED1” = Fragment 2 of Amendment 2 Fragments are independently approved and have their own lifecycle stages.

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    code: :pwi_frag,
    stage_code: :pwi,
    type_code: :frag,
    abbr: ["PWI Frag"],
    name: "Preliminary Work Item Fragment",
    harmonized_stages: %w[00.00 00.20 00.60 00.98 00.99],
  ),
  Pubid::Components::TypedStage.new(
    code: :np_frag,
    stage_code: :np,
    type_code: :frag,
    abbr: ["NP Frag"],
    name: "New Proposal Fragment",
    harmonized_stages: %w[10.00 10.20 10.60 10.92 10.98],
  ),
  Pubid::Components::TypedStage.new(
    code: :anw_frag,
    stage_code: :anw,
    type_code: :frag,
    abbr: ["ANW Frag"],
    name: "Approved New Work Item Fragment",
    harmonized_stages: %w[10.99 20.00],
  ),
  Pubid::Components::TypedStage.new(
    code: :wd_frag,
    stage_code: :wd,
    type_code: :frag,
    abbr: ["WD Frag"],
    name: "Working Draft Fragment",
    harmonized_stages: %w[20.20 20.60 20.98 20.99],
  ),
  Pubid::Components::TypedStage.new(
    code: :cdfrag,
    stage_code: :cd,
    type_code: :frag,
    abbr: ["CDFRAG"],
    name: "Committee Draft Fragment",
    harmonized_stages: %w[30.00 30.20 30.60 30.92 30.98 30.99],
  ),
  Pubid::Components::TypedStage.new(
    code: :dfrag,
    stage_code: :dfrag,
    type_code: :frag,
    abbr: ["DFRAG"],
    name: "Draft Fragment",
    harmonized_stages: %w[40.00 40.20 40.60 40.92 40.98 40.99],
  ),
  Pubid::Components::TypedStage.new(
    code: :fdfrag,
    stage_code: :fdfrag,
    type_code: :frag,
    abbr: ["FDFRAG", "PRF Frag"],
    name: "Final Draft Fragment",
    harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
  ),
  Pubid::Components::TypedStage.new(
    code: :frag,
    stage_code: :published,
    type_code: :frag,
    abbr: ["FRAG"],
    name: "Fragment",
    harmonized_stages: %w[60.00 60.60 90.20 90.60 90.92 90.93 90.99
                          95.20 95.60 95.92 95.99],
  ),
].freeze

Constants inherited from Pubid::Iec::Identifier

Pubid::Iec::Identifier::IEC_TYPE_MAP

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pubid::Iec::Identifier

#all_parts_from_kv, #all_parts_to_kv, #build_code, build_type_map, #copublishers_from_kv, default_publisher, #emit_code, from_hash, #number_from_kv, parse, #part_from_kv, published_typed_stage, #publisher_from_kv, #stage_from_kv, #stage_iteration_from_kv, #stage_to_kv, #subpart_from_kv, #type, #year_from_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

Class Method Details

.typeObject



116
117
118
119
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 116

def self.type
  { key: :frag,
    web: :fragment_identifier, title: "Fragment", short: "FRAG" }
end

Instance Method Details

#base_from_kv(model, value) ⇒ Object



44
45
46
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 44

def base_from_kv(model, value)
  model.base_identifier = ::Pubid::Iec::Identifier.from_hash(value) if value
end

#base_to_kv(model, doc) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 36

def base_to_kv(model, doc)
  base = model.base_identifier
  return unless base

  doc.add_child(Lutaml::KeyValue::DataModel::Element.new("base",
                                                        base.to_hash))
end

#codeObject



134
135
136
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 134

def code
  base_identifier&.code
end

#copublishersObject



130
131
132
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 130

def copublishers
  base_identifier&.copublishers
end

#copublishers_to_kv(_model, _doc) ⇒ Object



34
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 34

def copublishers_to_kv(_model, _doc); end

#dateObject



142
143
144
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 142

def date
  base_identifier&.date
end

#numberObject



138
139
140
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 138

def number
  base_identifier&.number
end

#number_to_kv(_model, _doc) ⇒ Object



28
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 28

def number_to_kv(_model, _doc); end

#part_to_kv(_model, _doc) ⇒ Object



29
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 29

def part_to_kv(_model, _doc); end

#publisherObject

Delegate common attributes to base_identifier



126
127
128
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 126

def publisher
  base_identifier&.publisher
end

#publisher_to_kv(_model, _doc) ⇒ Object



33
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 33

def publisher_to_kv(_model, _doc); end

#stageObject



146
147
148
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 146

def stage
  typed_stage&.to_stage || base_identifier&.stage
end

#stage_iteration_to_kv(_model, _doc) ⇒ Object



31
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 31

def stage_iteration_to_kv(_model, _doc); end

#subpart_to_kv(_model, _doc) ⇒ Object



30
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 30

def subpart_to_kv(_model, _doc); end

#to_s(**opts) ⇒ Object



121
122
123
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 121

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

#year_to_kv(_model, _doc) ⇒ Object



32
# File 'lib/pubid/iec/identifiers/fragment_identifier.rb', line 32

def year_to_kv(_model, _doc); end