Class: Pubid::Nist::Identifiers::Circular

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

Overview

NBS Circular Identifier Examples:

  • “NBS CIRC 13e2revJune1908” = Circular 13, edition 2, revised June 1908

  • “NBS CIRC 13” = Circular 13

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    abbr: ["CIRC", "NBS CIRC"],
    stage_code: "published",
    type_code: "circ",
  ),
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#edition_greater?, #extract_edition_number, #initialize, #language, #merge, #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/circular.rb', line 24

def type
  { key: :circ, title: "NBS Circular", short: "CIRC" }
end

.typed_stagesObject



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

def typed_stages
  TYPED_STAGES
end

Instance Method Details

#default_publisherObject



31
32
33
# File 'lib/pubid/nist/identifiers/circular.rb', line 31

def default_publisher
  "NBS"
end

#publisherObject

Convenience methods for tests that expect string values



40
41
42
# File 'lib/pubid/nist/identifiers/circular.rb', line 40

def publisher
  super&.to_s || default_publisher
end

#seriesObject



44
45
46
# File 'lib/pubid/nist/identifiers/circular.rb', line 44

def series
  super&.to_s || series_code
end

#series_codeObject



35
36
37
# File 'lib/pubid/nist/identifiers/circular.rb', line 35

def series_code
  "CIRC"
end

#to_s(format = nil) ⇒ Object

Override to_s for CIRC-specific edition+year rendering CIRC uses dot notation: “NBS CIRC 11e2.1915” instead of “NBS CIRC 11e2-1915”



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pubid/nist/identifiers/circular.rb', line 50

def to_s(format = nil)
  result = super

  # For CIRC edition patterns with additional_text (year), render with dot notation
  # "11e2-1915" format: edition.id="2", additional_text="1915" → render as "11e2.1915"
  if edition && edition.type == "e" && edition.additional_text&.match?(/^\d{4}$/)
    # Replace "11e1915" with "11e2.1915" format
    # Pattern: number + "e" + year (where year was stored in edition.id)
    # Need to reconstruct: number + "e" + edition.id + "." + additional_text
    result = result.gsub(/e(\d{4})$/,
                         "e#{edition.id || '?'}.#{edition.additional_text}")
  end

  result
end