Class: Pubid::Api::Scheme
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
.identifiers ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/pubid/api/scheme.rb', line 18
def identifiers
[
Identifiers::Standard,
Identifiers::RecommendedPractice,
Identifiers::Specification,
Identifiers::TechnicalReport,
Identifiers::Bulletin,
Identifiers::Mpms,
Identifiers::ContinuousOperationsStandard,
Identifiers::Publication,
Identifiers::TypelessStandard,
]
end
|
.locate_identifier_klass_by_type_code(type_code) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/pubid/api/scheme.rb', line 51
def locate_identifier_klass_by_type_code(type_code)
identifier_klass = identifiers.detect do |klass|
klass.type[:key].to_s == type_code.to_s
end
unless identifier_klass
raise ArgumentError,
"Unknown type code: #{type_code}"
end
identifier_klass
end
|
.locate_typed_stage_by_abbr(abbr) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/pubid/api/scheme.rb', line 36
def locate_typed_stage_by_abbr(abbr)
abbr = "API" if abbr.nil? || abbr.to_s.empty?
typed_stage = typed_stages.detect do |ts|
ts.abbr.include?(abbr)
end
unless typed_stage
raise ArgumentError,
"Unknown type abbreviation: '#{abbr}'"
end
typed_stage
end
|
.typed_stages ⇒ Object
32
33
34
|
# File 'lib/pubid/api/scheme.rb', line 32
def typed_stages
identifiers.flat_map { |klass| klass::TYPED_STAGES }
end
|