Class: Pubid::Nist::Identifiers::TechnicalNote
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Identifier
- Base
- Pubid::Nist::Identifiers::TechnicalNote
- 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
Constants inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #series_code ⇒ Object
- #to_s(format = nil) ⇒ Object
- #to_short_style ⇒ Object
-
#update_component=(value) ⇒ Object
Override update_component setter to add default year for TN dash-prefix updates.
Methods inherited from Base
#==, #append_mr_components, #append_short_components, #default_publisher, #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, #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
24 25 26 27 |
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 24 def type { key: :tn, web: :technical_note, title: "NIST Technical Note", short: "TN" } end |
.typed_stages ⇒ Object
20 21 22 |
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 20 def typed_stages TYPED_STAGES end |
Instance Method Details
#series_code ⇒ Object
30 31 32 |
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 30 def series_code "TN" end |
#to_s(format = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 54 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 |
#to_short_style ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 72 def to_short_style # Call parent implementation result = super # TN-SPECIFIC: For edition years (not with edition number), use 'e' prefix instead of dash # Pattern: "NIST TN 1297-1993" → "NIST TN 1297e1993" # But only if edition_year is set and edition is NOT set if !edition && edition_year # Replace the last occurrence of "-YYYY" with "eYYYY" # This handles both "-1993" and "-Feb1985" formats result = result.sub(/-(\d{4})$/, 'e\1') result = result.sub(/-([A-Za-z]{3,9})(\d{4})$/, 'e\1\2') end result end |
#update_component=(value) ⇒ Object
Override update_component setter to add default year for TN dash-prefix updates
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pubid/nist/identifiers/technical_note.rb', line 35 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 |