Class: RelatonBib::StructuredIdentifier
Constant Summary
Constants included
from RelatonBib
VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from RelatonBib
array, format_date, grammar_hash, parse_date, parse_yaml
Methods included from Config
#configuration, #configure
Constructor Details
Returns a new instance of StructuredIdentifier.
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/relaton_bib/structured_identifier.rb', line 85
def initialize(docnumber:, **args)
@type = args[:type]
@agency = args[:agency]
@klass = args[:class]
@docnumber = docnumber
@partnumber = args[:partnumber]
@edition = args[:edition]
@version = args[:version]
@supplementtype = args[:supplementtype]
@supplementnumber = args[:supplementnumber]
@language = args[:language]
@year = args[:year]
end
|
Instance Attribute Details
#agency ⇒ Array<String>
65
66
67
|
# File 'lib/relaton_bib/structured_identifier.rb', line 65
def agency
@agency
end
|
#docnumber ⇒ String
62
63
64
|
# File 'lib/relaton_bib/structured_identifier.rb', line 62
def docnumber
@docnumber
end
|
#edition ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def edition
@edition
end
|
#klass ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def klass
@klass
end
|
#language ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def language
@language
end
|
#partnumber ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def partnumber
@partnumber
end
|
#supplementnumber ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def supplementnumber
@supplementnumber
end
|
#supplementtype ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def supplementtype
@supplementtype
end
|
#type ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def type
@type
end
|
#version ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def version
@version
end
|
#year ⇒ String?
68
69
70
|
# File 'lib/relaton_bib/structured_identifier.rb', line 68
def year
@year
end
|
Instance Method Details
#all_parts ⇒ Object
169
170
171
|
# File 'lib/relaton_bib/structured_identifier.rb', line 169
def all_parts
@docnumber = @docnumber + " (all parts)"
end
|
#remove_date ⇒ Object
154
155
156
157
158
159
160
161
|
# File 'lib/relaton_bib/structured_identifier.rb', line 154
def remove_date
if @type == "Chinese Standard"
@docnumber.sub!(/-[12]\d\d\d/, "")
else
@docnumber.sub!(/:[12]\d\d\d/, "")
end
@year = nil
end
|
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year
164
165
166
167
|
# File 'lib/relaton_bib/structured_identifier.rb', line 164
def remove_part
@partnumber = nil
@docnumber = @docnumber.sub(/-\d+/, "")
end
|
#to_asciibib(prefix) ⇒ String
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/relaton_bib/structured_identifier.rb', line 137
def to_asciibib(prefix) out = "#{prefix}.docnumber:: #{docnumber}\n"
agency.each { |a| out += "#{prefix}.agency:: #{a}\n" }
out += "#{prefix}.type:: #{type}\n" if type
out += "#{prefix}.class:: #{klass}\n" if klass
out += "#{prefix}.partnumber:: #{partnumber}\n" if partnumber
out += "#{prefix}.edition:: #{edition}\n" if edition
out += "#{prefix}.version:: #{version}\n" if version
out += "#{prefix}.supplementtype:: #{supplementtype}\n" if supplementtype
if supplementnumber
out += "#{prefix}.supplementnumber:: #{supplementnumber}\n"
end
out += "#{prefix}.language:: #{language}\n" if language
out += "#{prefix}.year:: #{year}\n" if year
out
end
|
#to_hash ⇒ Hash
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/relaton_bib/structured_identifier.rb', line 119
def to_hash
hash = { "docnumber" => docnumber }
hash["type"] = type if type
hash["agency"] = single_element_array agency if agency&.any?
hash["class"] = klass if klass
hash["partnumber"] = partnumber if partnumber
hash["edition"] = edition if edition
hash["version"] = version if version
hash["supplementtype"] = supplementtype if supplementtype
hash["supplementnumber"] = supplementnumber if supplementnumber
hash["language"] = language if language
hash["year"] = year if year
hash
end
|
#to_xml(builder) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/relaton_bib/structured_identifier.rb', line 102
def to_xml(builder)
xml = builder.structuredidentifier do |b|
agency&.each { |a| b.agency a }
b.class_ klass if klass
b.docnumber docnumber
b.partnumber partnumber if partnumber
b.edition edition if edition
b.version version if version
b.supplementtype supplementtype if supplementtype
b.supplementnumber supplementnumber if supplementnumber
b.language language if language
b.year year if year
end
xml[:type] = type if type
end
|