Class: IsoBibItem::IsoBibliographicItem
Overview
Instance Attribute Summary collapse
#abstract, #contributors, #copyright, #dates, #fetched, #formatted_ref, #id, #language, #link, #notes, #relations, #script, #series
Instance Method Summary
collapse
#shortref
Constructor Details
Returns a new instance of IsoBibliographicItem.
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 167
def initialize(**args)
super_args = args.select do |k|
%i[
id language script dates abstract contributors relations copyright link
].include? k
end
super(super_args)
args[:docid] = [args[:docid]] unless args[:docid].is_a?(Array)
@docidentifier = args[:docid].map do |t|
t.is_a?(Hash) ? IsoDocumentId.new(t) : t
end
@edition = args[:edition]
@title = args[:titles].map do |t|
t.is_a?(Hash) ? IsoLocalizedTitle.new(t) : t
end
@type = args[:type]
@status = if args[:docstatus].is_a?(Hash)
IsoDocumentStatus.new(args[:docstatus])
else args[:docstatus] end
if args[:workgroup]
@workgroup = if args[:workgroup].is_a?(Hash)
IsoProjectGroup.new(args[:workgroup])
else args[:workgroup] end
end
@ics = args[:ics].map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
@link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
@id_attribute = true
end
|
Instance Attribute Details
125
126
127
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 125
def docidentifier
@docidentifier
end
|
#edition ⇒ String
128
129
130
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 128
def edition
@edition
end
|
143
144
145
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 143
def ics
@ics
end
|
137
138
139
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 137
def status
@status
end
|
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 130
|
#type ⇒ IsoBibItem::IsoDocumentType
134
135
136
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 134
def type
@type
end
|
140
141
142
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 140
def workgroup
@workgroup
end
|
Instance Method Details
#disable_id_attribute ⇒ Object
196
197
198
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 196
def disable_id_attribute
@id_attribute = false
end
|
#to_all_parts ⇒ Object
remove title part components and abstract
201
202
203
204
205
206
207
208
209
210
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 201
def to_all_parts
me = DeepClone.clone(self)
me.disable_id_attribute
@relations << DocumentRelation.new(type: "partOf", identifier: nil, url: nil, bibitem: me)
@title.each(&:remove_part)
@abstract = []
@docidentifier.each(&:remove_part)
@docidentifier.each(&:all_parts)
@all_parts = true
end
|
#to_most_recent_reference ⇒ Object
convert ISO:yyyy reference to reference to most recent instance of reference, removing date-specific infomration: date of publication, abstracts. Make dated reference Instance relation of the redacated document
216
217
218
219
220
221
222
223
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 216
def to_most_recent_reference
me = DeepClone.clone(self)
me.disable_id_attribute
@relations << DocumentRelation.new(type: "instance", identifier: nil, url: nil, bibitem: me)
@abstract = []
@dates = []
@docidentifier.each(&:remove_date)
end
|
#to_xml(builder = nil, **opts, &block) ⇒ String
242
243
244
245
246
247
248
249
250
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 242
def to_xml(builder = nil, **opts, &block)
if builder
render_xml builder, opts, &block
else
Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
render_xml xml, opts, &block
end.doc.root.to_xml
end
end
|
#url(type = :src) ⇒ String
237
238
239
|
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 237
def url(type = :src)
@link.find { |s| s.type == type.to_s }.content.to_s
end
|