Class: Pubid::Oiml::UrnGenerator
Instance Attribute Summary
#identifier
Instance Method Summary
collapse
#initialize, #maybe, #urn_edition, #urn_namespace, #urn_part, #urn_publisher, #urn_subpart, #urn_year
Instance Method Details
#bulletin_locator ⇒ Object
Structured locator "YYYY-II-SS" (or "YYYY-II" / "YYYY") for a Bulletin.
Built directly from the date year and the issue/sequence attributes so
the URN is identical regardless of whether the input was the structured
or citation form.
70
71
72
73
74
75
|
# File 'lib/pubid/oiml/urn_generator.rb', line 70
def bulletin_locator
locator = identifier.date.year.to_s
locator += "-#{identifier.issue}" if identifier.issue
locator += "-#{identifier.sequence}" if identifier.sequence
locator
end
|
#generate ⇒ Object
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/oiml/urn_generator.rb', line 30
def generate
if identifier.is_a?(Identifiers::Bulletin)
parts = ["urn", "oiml", "bulletin"]
parts << bulletin_locator if identifier.date&.present?
parts << urn_language if urn_language
return parts.join(":")
end
parts = ["urn", "oiml"]
parts << urn_type
parts << urn_number if urn_number
parts << urn_year if urn_year
parts << urn_stage if urn_stage
parts << urn_iteration if urn_iteration
parts << urn_language if urn_language
parts[1] = identifier.publisher.to_s.downcase if identifier.publisher
if identifier.is_a?(SupplementIdentifier)
if identifier.typed_stage
supp_type = identifier.typed_stage.type_code.to_s
parts << supp_type if supp_type
end
if identifier.number
parts << identifier.number.to_s
end
end
parts.join(":")
end
|
#urn_iteration ⇒ Object
22
23
24
|
# File 'lib/pubid/oiml/urn_generator.rb', line 22
def urn_iteration
identifier.iteration&.to_s
end
|
#urn_language ⇒ Object
26
27
28
|
# File 'lib/pubid/oiml/urn_generator.rb', line 26
def urn_language
identifier.language&.to_s&.downcase
end
|
#urn_number ⇒ Object
12
13
14
15
16
|
# File 'lib/pubid/oiml/urn_generator.rb', line 12
def urn_number
return nil unless identifier.code
identifier.code.to_s
end
|
#urn_stage ⇒ Object
18
19
20
|
# File 'lib/pubid/oiml/urn_generator.rb', line 18
def urn_stage
identifier.stage&.to_s&.downcase
end
|
#urn_type ⇒ Object
6
7
8
9
10
|
# File 'lib/pubid/oiml/urn_generator.rb', line 6
def urn_type
return "r" unless identifier.type
identifier.type.to_s.downcase
end
|