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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/pubid/api/builder.rb', line 17
def build(parsed_hash)
identifier_class = case parsed_hash[:type]&.to_s
when "BULL"
Identifiers::Bulletin
when "MPMS"
Identifiers::Mpms
when "RP"
Identifiers::RecommendedPractice
when "SPEC"
Identifiers::Specification
when "STD"
Identifiers::Standard
when "TR"
Identifiers::TechnicalReport
when "COS"
Identifiers::ContinuousOperationsStandard
when "PUBL"
Identifiers::Publication
else
Identifiers::TypelessStandard
end
identifier = identifier_class.new
if parsed_hash[:number]
identifier.code = Components::Code.new(value: parsed_hash[:number].to_s)
end
if parsed_hash[:part]
identifier.part = parsed_hash[:part].to_s
end
if parsed_hash[:chapter]
identifier.chapter = parsed_hash[:chapter].to_s
end
if parsed_hash[:section]
identifier.section = parsed_hash[:section].to_s
end
if parsed_hash[:subsection]
identifier.subsection = parsed_hash[:subsection].to_s
end
if parsed_hash[:year]
identifier.year = parsed_hash[:year].to_s
end
if parsed_hash[:reaffirmation]
reaffirm_data = parsed_hash[:reaffirmation]
identifier.reaffirmation = if reaffirm_data.is_a?(Hash) && reaffirm_data[:year]
reaffirm_data[:year].to_s
else
reaffirm_data.to_s
end
end
identifier
end
|