Class: Pubid::Nist::Identifiers::CrplReport
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Identifier
- Base
- Pubid::Nist::Identifiers::CrplReport
- 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
Constants inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #default_publisher ⇒ Object
-
#normalized_number ⇒ Object
Return normalized number value for tests - c4-4 → 4-4 (remove ‘c’ prefix) - 4-m-5 → 4-M-5 (uppercase ‘m’).
-
#number ⇒ Object
Override number to return normalized value Tests expect number.value to be normalized (c4-4 → 4-4, 4-m-5 → 4-M-5).
- #series_code ⇒ Object
- #to_s(format = nil) ⇒ Object
Methods inherited from Base
#==, #append_mr_components, #append_short_components, #edition_greater?, #exclude, #extract_edition_number, #hash, #initialize, #language, #matches?, #merge, #publisher_abbreviated_name, #publisher_full_name, #render, #revision, #series_abbreviated_name, #series_full_name, #supplement_short, #to_abbreviated_style, #to_full_style, #to_mr_style, #to_short_style, #translation, #weight
Methods included from Pubid::Nist::Identifier
Methods included from IdentifierFacade
#from_hash, #polymorphic_type_map
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, #year
Constructor Details
This class inherits a constructor from Pubid::Nist::Identifiers::Base
Class Method Details
.type ⇒ Object
26 27 28 29 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 26 def type { key: :crpl, web: :crpl_report, title: "NBS CRPL Report", short: "CRPL" } end |
.typed_stages ⇒ Object
22 23 24 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 22 def typed_stages TYPED_STAGES end |
Instance Method Details
#default_publisher ⇒ Object
35 36 37 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 35 def default_publisher "NBS" end |
#normalized_number ⇒ Object
Return normalized number value for tests
-
c4-4 → 4-4 (remove ‘c’ prefix)
-
4-m-5 → 4-M-5 (uppercase ‘m’)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 46 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 |
#number ⇒ Object
Override number to return normalized value Tests expect number.value to be normalized (c4-4 → 4-4, 4-m-5 → 4-M-5)
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 68 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(value: num_value) end |
#series_code ⇒ Object
39 40 41 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 39 def series_code "CRPL" end |
#to_s(format = nil) ⇒ Object
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 |
# File 'lib/pubid/nist/identifiers/crpl_report.rb', line 90 def to_s(format = nil) # 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 # Append the shared component tail (part, supplement, edition, # index, section, ...) so distinct CRPL reports do not collide. # range_notation is CRPL-specific and always trails the identifier. result += append_short_components result += range_notation if range_notation result end |