Class: Pubid::Iso::Urn
Constant Summary
collapse
- STAGES =
{ PWI: 0,
NP: 10,
AWI: 20,
WD: 20.20,
CD: 30,
DIS: 40,
FDIS: 50,
PRF: 50,
IS: 60 }.freeze
Constants inherited
from Identifier
Identifier::LANGUAGES
Instance Attribute Summary
Attributes inherited from Identifier
#amendment, #amendment_number, #amendment_stage, #amendment_version, #copublisher, #corrigendum, #corrigendum_number, #corrigendum_stage, #corrigendum_version, #joint_document, #number, #publisher, #scnumber, #substage, #supplements, #tcnumber, #urn_stage, #wgnumber, #year
Instance Method Summary
collapse
Methods inherited from Identifier
#get_params, #identifier, parse, parse_from_title, #rendered_year, #urn
Constructor Details
#initialize(**opts) ⇒ Urn
Returns a new instance of Urn.
14
15
16
|
# File 'lib/pubid/iso/urn.rb', line 14
def initialize(**opts)
opts.each { |key, value| send("#{key}=", value) }
end
|
Instance Method Details
#edition ⇒ Object
86
87
88
|
# File 'lib/pubid/iso/urn.rb', line 86
def edition
":ed-#{@edition}" if @edition
end
|
#iteration ⇒ Object
90
91
92
|
# File 'lib/pubid/iso/urn.rb', line 90
def iteration
".v#{@iteration}" if @iteration
end
|
#language ⇒ Object
122
123
124
125
126
|
# File 'lib/pubid/iso/urn.rb', line 122
def language
if @language
":#{@language}"
end
end
|
#originator ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/pubid/iso/urn.rb', line 72
def originator
if @copublisher
@copublisher = [@copublisher] unless @copublisher.is_a?(Array)
@publisher.downcase + @copublisher.map(&:to_s).sort.map do |copublisher|
"-#{copublisher.downcase.gsub('/', '-')}"
end.join
else
@publisher.downcase
end
end
|
#part ⇒ Object
52
53
54
|
# File 'lib/pubid/iso/urn.rb', line 52
def part
":-#{@part}" if @part
end
|
#render_stage(stage) ⇒ Object
56
57
58
59
60
|
# File 'lib/pubid/iso/urn.rb', line 56
def render_stage(stage)
return ":stage-#{sprintf('%05.2f', stage)}#{iteration}" if stage.is_a?(Float)
":stage-#{sprintf('%05.2f', STAGES[stage.to_sym])}#{iteration}"
end
|
#sctype ⇒ Object
36
37
38
39
40
|
# File 'lib/pubid/iso/urn.rb', line 36
def sctype
return unless @sctype
":#{@sctype.downcase}:#{@scnumber}"
end
|
#stage ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/pubid/iso/urn.rb', line 62
def stage
return render_stage(@urn_stage) if @urn_stage
return render_stage(@stage) if @stage
return render_stage(@amendment_stage) if @amendment_stage
render_stage(@corrigendum_stage) if @corrigendum_stage
end
|
#supplement ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/pubid/iso/urn.rb', line 102
def supplement
result = ""
if @amendment
result += if @amendment_number
":amd:#{@amendment_number}:v#{@amendment_version}"
else
":amd:#{@amendment_version}:v1"
end
end
if @corrigendum
result += if @corrigendum_number
":cor:#{@corrigendum_number}:v#{@corrigendum_version}"
else
":cor:#{@corrigendum_version}:v1"
end
end
result
end
|
#tctype ⇒ Object
30
31
32
33
34
|
# File 'lib/pubid/iso/urn.rb', line 30
def tctype
return @tctype.join(":") if @tctype.is_a?(Array)
@tctype
end
|
#to_s ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/pubid/iso/urn.rb', line 18
def to_s
if tctype
"urn:iso:doc:#{originator}:#{tctype.downcase}:#{tcnumber}#{sctype}#{wgtype}:#{number}"
else
"urn:iso:std:#{originator}#{type}:#{number}#{part}#{stage}#{edition}#{supplement}#{language}"
end
end
|
#type ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/pubid/iso/urn.rb', line 94
def type
if @type
":#{@type.downcase}"
end
end
|
#wgtype ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/pubid/iso/urn.rb', line 42
def wgtype
return unless @wgtype
if @wgnumber
":#{@wgtype.downcase}:#{@wgnumber}"
else
":#{@wgtype.downcase}"
end
end
|