Class: Pubid::Ieee::Scheme

Inherits:
Scheme
  • Object
show all
Defined in:
lib/pubid/ieee/scheme.rb

Overview

Scheme provides registry access for IEEE identifiers Following the proven ISO/IEC/CEN/BSI pattern

This class is the single source of truth for:

  • TypedStage lookup by abbreviation

  • TypedStage lookup by IEEE draft notation

  • TypedStage lookup by ISO stage code

  • Identifier class selection based on type code

Instance Attribute Summary

Attributes inherited from Scheme

#identifiers, #languages, #publishers, #stages, #supplement_identifiers, #types

Class Method Summary collapse

Methods inherited from Scheme

#all_identifier_classes, #all_typed_stages, #configure, #identifier_class_index, #initialize, #locate_identifier_klass_by_type_code, #locate_typed_stage_by_abbr, #locate_typed_stage_by_harmonized_code, #locate_typed_stage_by_stage_code, #supplement_typed_stages, #typed_stage_index, #typed_stages

Constructor Details

This class inherits a constructor from Pubid::Scheme

Class Method Details

.default_typed_stageComponents::TypedStage

Get default typed stage (published standard)

Returns:



84
85
86
# File 'lib/pubid/ieee/scheme.rb', line 84

def default_typed_stage
  TypedStages::DEFAULT_TYPED_STAGE
end

.locate_identifier_klass_by_type_code(type_code) ⇒ Class

Locate identifier class by type code

Parameters:

  • type_code (String, Symbol)

    type code (:standard, :draft, :std, :P, etc.)

Returns:

  • (Class)

    identifier class



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/pubid/ieee/scheme.rb', line 61

def locate_identifier_klass_by_type_code(type_code)
  type_str = type_code.to_s

  case type_str
  when "draft", "Draft Std", "Draft", "P"
    # "P" indicates project draft status - maps to ProjectDraftIdentifier
    Identifiers::ProjectDraftIdentifier
  when "standard", "Std", "std"
    Identifiers::Standard
  else
    # Default to base identifier
    Identifiers::Base
  end
end

.locate_typed_stage_by_abbr(abbr) ⇒ Components::TypedStage

Locate typed stage by abbreviation

Parameters:

  • abbr (String, nil)

    stage abbreviation (e.g., “D1”, “FDIS”, “Std”)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pubid/ieee/scheme.rb', line 20

def locate_typed_stage_by_abbr(abbr)
  return TypedStages::DEFAULT_TYPED_STAGE if abbr.nil? || abbr.to_s.strip.empty?

  # Normalize abbreviation
  abbr_str = abbr.to_s.strip

  # Find typed stage that includes this abbreviation
  typed_stage = TypedStages::TYPED_STAGES.find { |ts| ts.abbr.include?(abbr_str) }

  # Fall back to default if not found
  typed_stage || TypedStages::DEFAULT_TYPED_STAGE
end

.locate_typed_stage_by_ieee_draft(draft) ⇒ Components::TypedStage?

Locate typed stage by IEEE draft notation

Parameters:

  • draft (String)

    IEEE draft notation (e.g., “D1”, “D5”, “P”)

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pubid/ieee/scheme.rb', line 36

def locate_typed_stage_by_ieee_draft(draft)
  return nil if draft.nil? || draft.to_s.strip.empty?

  draft_str = draft.to_s.strip

  # Try exact match on abbreviation first
  ts = TypedStages::TYPED_STAGES.find { |t| t.abbr.include?(draft_str) }
  return ts if ts

  # Try match on ieee_draft_equivalent
  TypedStages::TYPED_STAGES.find { |t| t.ieee_draft_equivalent == draft_str }
end

.locate_typed_stage_by_iso_stage(stage) ⇒ Components::TypedStage?

Locate typed stage by ISO stage code

Parameters:

  • stage (String)

    ISO stage code (e.g., “WD”, “CD”, “DIS”, “FDIS”)

Returns:



52
53
54
55
56
# File 'lib/pubid/ieee/scheme.rb', line 52

def locate_typed_stage_by_iso_stage(stage)
  return nil if stage.nil? || stage.to_s.strip.empty?

  TypedStages::TYPED_STAGES.find { |ts| ts.iso_stage_equivalent == stage.to_s.strip }
end

.typed_stagesArray<Components::TypedStage>

Get all typed stages

Returns:



78
79
80
# File 'lib/pubid/ieee/scheme.rb', line 78

def typed_stages
  TypedStages::TYPED_STAGES
end