Class: Pubid::Ieee::Builder

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

Overview

Builder class for constructing IEEE identifier scheme from parsed data Single Responsibility: Transform parsed data into Scheme objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier_class = Identifiers::Base) ⇒ Builder

Returns a new instance of Builder.



11
12
13
# File 'lib/pubid/ieee/builder.rb', line 11

def initialize(identifier_class = Identifiers::Base)
  @identifier_class = identifier_class
end

Instance Attribute Details

#identifier_classObject (readonly)

Returns the value of attribute identifier_class.



9
10
11
# File 'lib/pubid/ieee/builder.rb', line 9

def identifier_class
  @identifier_class
end

#original_inputObject

Returns the value of attribute original_input.



8
9
10
# File 'lib/pubid/ieee/builder.rb', line 8

def original_input
  @original_input
end

Instance Method Details

#build(parsed) ⇒ Scheme

Build a scheme object from parsed data

Parameters:

  • parsed (Hash, Array)

    the parsed identifier data

Returns:

  • (Scheme)

    the constructed scheme object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pubid/ieee/builder.rb', line 18

def build(parsed)
  # Handle CSA dual published patterns
  if parsed[:ieee_portion] && parsed[:csa_portion]
    return build_csa_dual_published(parsed)
  end

  # Handle combined AIEE identifiers (from "Nos X and Y" preprocessing)
  if parsed[:first_aiee] && parsed[:second_aiee]
    return build_combined_aiee(parsed)
  end

  # Handle dual published patterns
  if parsed[:first] && parsed[:second]
    return build_dual_published(parsed)
  end

  # Handle IEC/IEEE copublished patterns
  if parsed[:content]
    return build_iec_ieee_copublished(parsed)
  end

  # Handle NESC identifiers (National Electrical Safety Code)
  if parsed[:nesc]
    nesc_builder = Nesc::Builder.new
    return nesc_builder.build(parsed[:nesc])
  end

  # Handle AIEE identifiers (American Institute of Electrical Engineers)
  if parsed[:aiee]
    aiee_builder = Aiee::Builder.new
    return aiee_builder.build(parsed[:aiee])
  end

  # Handle IRE identifiers (Institute of Radio Engineers)
  if parsed[:ire]
    ire_builder = Ire::Builder.new
    return ire_builder.build(parsed[:ire])
  end

  # Handle IEEE/ASTM SI/PSI identifiers (Système International)
  if parsed[:si_type]
    return build_si_psi_identifier(parsed)
  end

  # Handle single identifier
  build_single_identifier(parsed)
end