Class: Pubid::Nist::Identifiers::Handbook

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

Overview

NIST Handbook (HB) Examples:

  • “NIST HB 130” = Handbook 130

  • “NBS HB 133” = NBS Handbook 133

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    abbr: ["HB", "NIST HB", "NBS HB"],
    stage_code: "published",
    type_code: "hb",
  ),
].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/handbook.rb', line 24

def type
  { key: :hb, title: "NIST Handbook", short: "HB" }
end

.typed_stagesObject



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

def typed_stages
  TYPED_STAGES
end

Instance Method Details

#series_codeObject



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

def series_code
  "HB"
end

#to_s(format = nil) ⇒ Object

Override to_s to handle edition+year pattern with dash instead of dot Pattern: “44e2-1955” (dash separator) not “44e2.1955” (dot separator)



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pubid/nist/identifiers/handbook.rb', line 35

def to_s(format = nil)
  # Use the base to_s method first
  result = super

  # If edition has additional_text (year), replace dot with dash
  if edition&.additional_text && !edition.additional_text.empty?
    result = result.gsub(/#{Regexp.escape(edition.type)}#{Regexp.escape(edition.id)}\.#{Regexp.escape(edition.additional_text)}/,
                         "#{edition.type}#{edition.id}-#{edition.additional_text}")
  end

  result
end