Class: Pubid::Iec::Identifiers::TestReportForm

Inherits:
Base show all
Defined in:
lib/pubid/iec/identifiers/test_report_form.rb

Overview

Test Report Form identifier class Single Responsibility: Represents IEC TRF documents Can embed CISPR identifiers for IECEE TRF format

Constant Summary collapse

TYPED_STAGES =

TRF has type abbreviation for parsing

[
  Pubid::Components::TypedStage.new(
    code: :trf,
    stage_code: :published,
    type_code: :trf,
    abbr: ["TRF"],
    name: "Test Report Form",
    harmonized_stages: %w[60.00 60.60],
  ),
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#number_portion, #validate!

Methods inherited from SingleIdentifier

#edition_portion, #language_portion, #number_portion

Methods inherited from Pubid::Iec::Identifier

parse

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

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.typeObject



28
29
30
# File 'lib/pubid/iec/identifiers/test_report_form.rb', line 28

def self.type
  { key: :trf, title: "Test Report Form", short: "TRF" }
end

Instance Method Details

#publisher_portionObject

Override publisher_portion to add TRF with space



33
34
35
36
37
38
39
40
41
# File 'lib/pubid/iec/identifiers/test_report_form.rb', line 33

def publisher_portion
  result = publisher.to_s

  if typed_stage && typed_stage.abbreviation == "TRF"
    result += " TRF"
  end

  result
end

#to_s(_format = :short) ⇒ Object

TRF uses special rendering



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/pubid/iec/identifiers/test_report_form.rb', line 44

def to_s(_format = :short)
  parts = []

  # Publisher and type portion
  parts << publisher_portion

  # If CISPR identifier embedded, render it with TRF date
  if cispr_identifier
    cispr_parts = []
    cispr_parts << cispr_identifier.publisher.body

    # Build number portion with part
    num_str = cispr_identifier.number.to_s
    num_str += "-#{cispr_identifier.part}" if cispr_identifier.part && cispr_identifier.part.to_s != ""
    cispr_parts << num_str

    # Join with space and add TRF year
    cispr_str = cispr_parts.join(" ")
    cispr_str += ":#{date.year}" if date

    parts << " #{cispr_str}"
  else
    # Normal TRF: number portion
    parts << number_portion
  end

  # TRF info if present (handles version, decision sheet, etc.)
  parts << trf_info.to_s if trf_info && !trf_info.empty?

  parts.compact.join
end