Module: Pubid::Nist::Series

Defined in:
lib/pubid/nist/series.rb,
lib/pubid/nist/series/ir.rb,
lib/pubid/nist/series/base.rb,
lib/pubid/nist/series/crpl.rb,
lib/pubid/nist/series/fips.rb,
lib/pubid/nist/series/mono.rb,
lib/pubid/nist/series/ncstar.rb,
lib/pubid/nist/series/letter_preserving.rb

Overview

Per-series behavior policies for the NIST caster and builder.

Series-specific casting decisions (letter-suffix preservation, IR revision handling, FIPS date format, etc.) live behind this interface so the caster and builder never read ‘parsed_hash` directly. A series bug now lives in exactly one file.

Defined Under Namespace

Classes: Base, Crpl, Fips, Ir, LetterPreserving, Mono, Ncstar

Constant Summary collapse

REGISTRY =

Order matters: longer / more-specific codes first so that substrings do not shadow them (e.g., LCIRC must be matched before IR, since “LCIRC” contains “IR”).

[
  ["LCIRC", LetterPreserving],
  ["FIPS",  Fips],
  ["CRPL",  Crpl],
  ["NCSTAR", Ncstar],
  ["MONO",  Mono],
  ["IR",    Ir],
  ["MP",    LetterPreserving],
  ["RPT",   LetterPreserving],
  ["LC",    LetterPreserving],
].freeze

Class Method Summary collapse

Class Method Details

.for(parsed_hash) ⇒ Object



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

def self.for(parsed_hash)
  return Base if parsed_hash.nil?

  series_code = parsed_hash[:series]
  return Base if series_code.nil?

  series_str = series_code.to_s.upcase
  REGISTRY.each do |code, klass|
    return klass if series_str.include?(code)
  end
  Base
end