Class: Pubid::Nist::Identifiers::CrplReport

Inherits:
Base
  • Object
show all
Defined in:
lib/pubid/nist/identifiers/crpl_report.rb

Overview

NBS CRPL (Central Radio Propagation Laboratory) Report Identifier Examples:

  • “NBS CRPL 1-2_3-1” = Reports 1-2 and 3-1 jointly

  • “NBS CRPL 4-m-5” = Report 4, month m, issue 5

  • “NBS CRPL c4-4” = Report c4, issue 4

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    abbr: ["CRPL", "NBS CRPL", "CRPL-F-B", "CRPL-F-A", "NBS CRPL-F-B",
           "NBS CRPL-F-A"],
    stage_code: "published",
    type_code: "crpl",
  ),
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#edition_greater?, #extract_edition_number, #initialize, #language, #merge, #publisher, #revision, #translation, #weight

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::Nist::Identifiers::Base

Class Method Details

.typeObject



26
27
28
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 26

def type
  { key: :crpl, title: "NBS CRPL Report", short: "CRPL" }
end

.typed_stagesObject



22
23
24
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 22

def typed_stages
  TYPED_STAGES
end

Instance Method Details

#default_publisherObject



34
35
36
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 34

def default_publisher
  "NBS"
end

#normalized_numberObject

Return normalized number value for tests

  • c4-4 → 4-4 (remove ‘c’ prefix)

  • 4-m-5 → 4-M-5 (uppercase ‘m’)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 45

def normalized_number
  return nil unless number

  num_value = number.value.to_s

  # Pattern: c4-4 → 4-4 (hide 'c' prefix)
  case num_value
  when /^c(\d+.*)$/
    num_value = $1
  # Pattern: 4-m-5 → 4-M-5 (uppercase 'm')
  when /-m-/
    num_value = num_value.gsub("-m-", "-M-")
  # Pattern: m-5 → M-5 (uppercase 'm' at start)
  when /^m-/
    num_value = num_value.gsub(/^m-/, "M-")
  end

  num_value
end

#numberObject

Override number to return normalized value Tests expect number.value to be normalized (c4-4 → 4-4, 4-m-5 → 4-M-5)



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 67

def number
  num = super
  return num unless num

  num_value = num.value.to_s

  # Pattern: c4-4 → 4-4 (hide 'c' prefix)
  case num_value
  when /^c(\d+.*)$/
    num_value = $1
  # Pattern: 4-m-5 → 4-M-5 (uppercase 'm')
  when /-m-/
    num_value = num_value.gsub("-m-", "-M-")
  # Pattern: m-5 → M-5 (uppercase 'm' at start)
  when /^m-/
    num_value = num_value.gsub(/^m-/, "M-")
  end

  # Return new Code object with normalized value
  Components::Code.new(number: num_value)
end

#series_codeObject



38
39
40
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 38

def series_code
  "CRPL"
end

#to_sObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 89

def to_s
  # Use actual series attribute if it contains subseries (e.g., "CRPL-F-B")
  # Otherwise use default series_code ("CRPL")
  series_to_render = if series&.value&.include?("CRPL-F-")
                       series.value.sub("NBS ", "") # Remove publisher prefix if present
                     else
                       series_code
                     end

  result = "#{default_publisher} #{series_to_render}"

  if number
    # Normalize number value for CRPL patterns
    num_value = number.value.to_s

    # Pattern: c4-4 → 4-4 (hide 'c' prefix)
    case num_value
    when /^c(\d+.*)$/
      num_value = $1
    # Pattern: 4-m-5 → 4-M-5 (uppercase 'm')
    when /-m-/
      num_value = num_value.gsub("-m-", "-M-")
    # Pattern: m-5 → M-5 (uppercase 'm' at start)
    when /^m-/
      num_value = num_value.gsub(/^m-/, "M-")
    end

    result += " #{prefix}" if prefix
    result += " #{num_value}"
  end

  # Add part component (pt3-1)
  result += part.to_s if part

  # Add supplement with "sup" prefix for CRPL identifiers
  if supplement
    # Check if supplement already has "sup" prefix (for backward compatibility)
    result += (supplement.start_with?("sup") ? supplement : "sup#{supplement}")
  end

  result += range_notation if range_notation
  result
end