Class: Pubid::Ieee::Aiee::Builder

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

Overview

Builder for AIEE identifiers

Instance Method Summary collapse

Instance Method Details

#build(parsed) ⇒ Object



8
9
10
11
12
13
14
15
16
17
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
# File 'lib/pubid/ieee/aiee/builder.rb', line 8

def build(parsed)
  attributes = {}

  # Extract and normalize publisher
  # All AIEE variants (AIEE, A.I.E.E., A. I. E. E., IEEE-AIEE) normalize to "AIEE"
  attributes[:publisher] = "AIEE"

  # Extract and normalize type
  type_str = extract_value(parsed[:type])
  # Normalize compound types like "Standard No." to "No"
  # Also normalize "Standard No" (without dot) to "No"
  attributes[:type] = if type_str&.start_with?("Standard")
                        "No"
                      else
                        type_str
                      end

  # Extract code
  code_str = extract_value(parsed[:number])
  if code_str
    attributes[:code] = Components::Code.parse(code_str)
  end

  # Extract year (convert to string for consistency)
  year_str = extract_value(parsed[:year])
  attributes[:year] = year_str&.to_s

  # Extract month
  month_str = extract_value(parsed[:month])
  attributes[:month] = month_str if month_str

  # Extract separator (for rendering distinction)
  separator_str = extract_value(parsed[:separator])
  attributes[:separator] = separator_str if separator_str

  # Set original format based on parsed data
  attributes[:original_format] = if separator_str || month_str
                                   "long"
                                 else
                                   "short"
                                 end

  # Create identifier
  Identifier.new(**attributes)
end