Class: Pubid::Nist::Identifiers::TechnicalNote

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

Overview

NIST Technical Note (TN) Examples:

  • “NIST TN 1234” = Technical Note 1234

  • “NBS TN 567” = NBS Technical Note 567

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    abbr: ["TN", "NIST TN", "NBS TN"],
    stage_code: "published",
    type_code: "tn",
  ),
].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



24
25
26
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 24

def type
  { key: :tn, title: "NIST Technical Note", short: "TN" }
end

.typed_stagesObject



20
21
22
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 20

def typed_stages
  TYPED_STAGES
end

Instance Method Details

#series_codeObject



29
30
31
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 29

def series_code
  "TN"
end

#to_s(format = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 53

def to_s(format = nil)
  # TN-SPECIFIC: Add default year to "-upd" pattern (no year/month)
  # Pattern: "NIST TN 2150-upd" → "NIST TN 2150/Upd1-202102"
  # This is a special TN pattern where -upd gets default number=1 and year=202102
  if update_component && !update_component.year && update_component.prefix == "dash"
    # Create new Update with default year 202102 (February 2021)
    # This ensures both rendering and attribute access work correctly
    self.update = Components::Update.new(number: update_component.number || "1",
                                         year: "2021", month: "02", prefix: "slash")
    self.update_component = update
  end

  # Call parent implementation
  super
end

#update_component=(value) ⇒ Object

Override update_component setter to add default year for TN dash-prefix updates



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 34

def update_component=(value)
  super

  # TN-SPECIFIC: Add default year to "-upd" pattern (no year/month)
  # Pattern: "NIST TN 2150-upd" → update gets default year=2021, month=02
  if value && value.prefix == "dash" && !value.year
    # Create new Update with default year 2021 and month 02
    default_update = Components::Update.new(
      number: value.number || "1",
      year: "2021",
      month: "02",
      prefix: "slash",
    )
    # Set both update and update_component to the new object
    super(default_update)
    self.update = default_update
  end
end