Class: Pubid::Csa::Builder

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

Instance Method Summary collapse

Instance Method Details

#build(parsed_hash) ⇒ Object



6
7
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
# File 'lib/pubid/csa/builder.rb', line 6

def build(parsed_hash)
  # Handle Canadian adopted identifiers (CAN/CSA- or CAN3- prefix)
  # Check this BEFORE series_type because CAN/CSA-X SERIES:YY should be
  # CanadianAdopted wrapping a Series, not a plain Series identifier
  if parsed_hash[:publisher_prefix] &&
      ["CAN/CSA-", "CAN3-"].include?(parsed_hash[:publisher_prefix].to_s)
    return build_canadian_adopted(parsed_hash)
  end

  # Handle adoption identifiers (ISO/IEC/CISPR/CEI adoptions)
  if parsed_hash.key?(:adoption_number)
    return build_adoption(parsed_hash)
  end

  # Handle series identifiers (SERIES as primary type)
  if parsed_hash.key?(:series_type)
    return build_series(parsed_hash)
  end

  # Handle CEC identifiers (C22.x NO. patterns)
  if parsed_hash.key?(:cec_part)
    return build_cec(parsed_hash)
  end

  # Handle package identifiers (with package_portion marker)
  if parsed_hash.key?(:package_portion)
    return build_package(parsed_hash)
  end

  # Handle bundled identifiers (with + notation)
  if parsed_hash.key?(:bundled_first)
    return build_bundled(parsed_hash)
  end

  # Handle combined identifiers (with / notation)
  if parsed_hash[:first] && parsed_hash[:second]
    return build_combined(parsed_hash)
  end

  build_single(parsed_hash)
end