Class: RelatonBib::BibliographicItem
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/biblio_version.rb,
lib/relaton_bib/bibliographic_item.rb
Overview
Bibliographic item
Defined Under Namespace
Classes: Version
Constant Summary collapse
- TYPES =
%W[article book booklet manual proceedings presentation thesis techreport standard unpublished map electronic\sresource audiovisual film video broadcast software graphic_work music patent inbook incollection inproceedings journal website webresource dataset archival social_media alert message conversation misc internal].freeze
Constants included from RelatonBib
Instance Attribute Summary collapse
- #abstract(lang: nil) ⇒ RelatonBib::FormattedString+
- #accesslocation ⇒ Array<Strig> readonly
- #all_parts ⇒ Boolean?
- #biblionote ⇒ RelatonBib::BiblioNoteCollection readonly
- #classification ⇒ Array<Relaton::Classification> readonly
- #contributor ⇒ Array<RelatonBib::ContributionInfo> readonly
- #copyright ⇒ Array<RelatonBib::CopyrightAssociation> readonly
- #date ⇒ Array<RelatonBib::BibliographicDate>
- #docidentifier ⇒ Array<RelatonBib::DocumentIdentifier> readonly
- #docnumber ⇒ String? readonly
- #doctype ⇒ String? readonly
-
#edition ⇒ RelatonBib::Edition?
readonly
<description>.
- #editorialgroup ⇒ RelatonBib::EditorialGroup? readonly
- #extent ⇒ Array<RelatonBib::Locality, RelatonBib::LocalityStack> readonly
- #fetched ⇒ Date
- #formattedref ⇒ RelatonBib::FormattedRef? readonly
- #ics ⇒ Array<RelatonBib:ICS> readonly
- #id ⇒ String? readonly
- #keyword ⇒ Array<RelatonBib::LocalizedString> readonly
-
#language ⇒ Array<String>
readonly
Language Iso639 code.
- #license ⇒ Array<Strig> readonly
- #link ⇒ Array<RelatonBib::TypedUri> readonly
- #medium ⇒ RelatonBib::Medium? readonly
- #place ⇒ Array<RelatonBib::Place> readonly
- #relation ⇒ RelatonBib::DocRelationCollection readonly
-
#script ⇒ Array<String>
readonly
Script Iso15924 code.
- #series ⇒ Array<RelatonBib::Series> readonly
- #size ⇒ RelatonBib::BibliographicSize? readonly
- #status ⇒ RelatonBib::DocumentStatus? readonly
- #structuredidentifier ⇒ RelatonBib::StructuredIdentifierCollection readonly
- #subdoctype ⇒ String? readonly
- #title(lang: nil) ⇒ RelatonIsoBib::TypedTitleStringCollection readonly
- #type ⇒ String? readonly
- #validity ⇒ RelatonBib:Validity? readonly
- #version ⇒ Array<RelatonBib::BibliographicItem::Version> readonly
Class Method Summary collapse
Instance Method Summary collapse
- #deep_clone ⇒ Object
- #disable_id_attribute ⇒ Object
-
#initialize(**args) ⇒ BibliographicItem
constructor
A new instance of BibliographicItem.
- #makeid(identifier, attribute) ⇒ String
-
#revdate ⇒ String?
If revision_date exists then returns it else returns published date or nil.
-
#schema ⇒ String
Fetch schema version.
-
#schema_versions ⇒ Hash{String=>String}
Read schema versions from file.
- #shortref(identifier, **opts) ⇒ String
-
#to_all_parts ⇒ Object
remove title part components and abstract.
- #to_asciibib(prefix = "") ⇒ String
-
#to_bibtex(bibtex = nil) ⇒ String
Reander BibTeX.
-
#to_bibxml(builder = nil, include_keywords: false) ⇒ String, Nokogiri::XML::Builder::NodeBuilder
Render BibXML (RFC).
-
#to_citeproc(bibtex = nil) ⇒ Hash
Render citeproc.
- #to_hash(embedded: false) ⇒ Hash
-
#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.
-
#to_xml(**opts, &block) ⇒ String
XML.
- #url(type = :src) ⇒ String?
Methods included from RelatonBib
array, format_date, grammar_hash, parse_date, parse_yaml
Methods included from Config
Constructor Details
#initialize(**args) ⇒ BibliographicItem
Returns a new instance of BibliographicItem.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 205 def initialize(**args) if args[:type] && !TYPES.include?(args[:type]) Util.warn %{WARNING: type `#{args[:type]}` is invalid.} end @title = if args[:title].is_a?(TypedTitleStringCollection) args[:title] else TypedTitleStringCollection.new(args[:title]) end @date = (args[:date] || []).map do |d| d.is_a?(Hash) ? BibliographicDate.new(**d) : d end @contributor = (args[:contributor] || []).map do |c| if c.is_a? Hash e = c[:entity].is_a?(Hash) ? Organization.new(**c[:entity]) : c[:entity] ContributionInfo.new(entity: e, role: c[:role]) else c end end @abstract = (args[:abstract] || []).map do |a| a.is_a?(Hash) ? FormattedString.new(**a) : a end @copyright = args.fetch(:copyright, []).map do |c| c.is_a?(Hash) ? CopyrightAssociation.new(**c) : c end @docidentifier = args[:docid] || [] @formattedref = args[:formattedref] if title.empty? @id = args[:id] || makeid(nil, false) @type = args[:type] @docnumber = args[:docnumber] @edition = case args[:edition] when Hash then Edition.new(**args[:edition]) when String, Integer, Float Edition.new(content: args[:edition].to_s) when Edition then args[:edition] end @version = args.fetch :version, [] @biblionote = args.fetch :biblionote, BiblioNoteCollection.new([]) @language = args.fetch :language, [] @script = args.fetch :script, [] @status = args[:docstatus] @relation = DocRelationCollection.new(args[:relation] || []) @link = args.fetch(:link, []).map do |s| case s when Hash then TypedUri.new(**s) when String then TypedUri.new(content: s) else s end end @series = args.fetch :series, [] @medium = args[:medium] @place = args.fetch(:place, []).map do |pl| pl.is_a?(String) ? Place.new(name: pl) : pl end @extent = args[:extent] || [] @size = args[:size] @accesslocation = args.fetch :accesslocation, [] @classification = args.fetch :classification, [] @validity = args[:validity] # we should pass the fetched arg from scrappers @fetched = args.fetch :fetched, nil @keyword = (args[:keyword] || []).map do |kw| case kw when Hash then LocalizedString.new(kw[:content], kw[:language], kw[:script]) when String then LocalizedString.new(kw) else kw end end @license = args.fetch :license, [] @doctype = args[:doctype] @subdoctype = args[:subdoctype] @editorialgroup = args[:editorialgroup] @ics = args.fetch :ics, [] @structuredidentifier = args[:structuredidentifier] end |
Instance Attribute Details
#abstract(lang: nil) ⇒ RelatonBib::FormattedString+
|
# File 'lib/relaton_bib/bibliographic_item.rb', line 84
|
#accesslocation ⇒ Array<Strig> (readonly)
109 110 111 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 109 def accesslocation @accesslocation end |
#all_parts ⇒ Boolean?
46 47 48 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 46 def all_parts @all_parts end |
#biblionote ⇒ RelatonBib::BiblioNoteCollection (readonly)
73 74 75 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 73 def biblionote @biblionote end |
#classification ⇒ Array<Relaton::Classification> (readonly)
112 113 114 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 112 def classification @classification end |
#contributor ⇒ Array<RelatonBib::ContributionInfo> (readonly)
67 68 69 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 67 def contributor @contributor end |
#copyright ⇒ Array<RelatonBib::CopyrightAssociation> (readonly)
91 92 93 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 91 def copyright @copyright end |
#date ⇒ Array<RelatonBib::BibliographicDate>
64 65 66 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 64 def date @date end |
#docidentifier ⇒ Array<RelatonBib::DocumentIdentifier> (readonly)
61 62 63 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 61 def docidentifier @docidentifier end |
#docnumber ⇒ String? (readonly)
49 50 51 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 49 def docnumber @docnumber end |
#doctype ⇒ String? (readonly)
49 50 51 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 49 def doctype @doctype end |
#edition ⇒ RelatonBib::Edition? (readonly)
Returns <description>.
52 53 54 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 52 def edition @edition end |
#editorialgroup ⇒ RelatonBib::EditorialGroup? (readonly)
124 125 126 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 124 def editorialgroup @editorialgroup end |
#extent ⇒ Array<RelatonBib::Locality, RelatonBib::LocalityStack> (readonly)
106 107 108 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 106 def extent @extent end |
#fetched ⇒ Date
118 119 120 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 118 def fetched @fetched end |
#formattedref ⇒ RelatonBib::FormattedRef? (readonly)
82 83 84 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 82 def formattedref @formattedref end |
#ics ⇒ Array<RelatonBib:ICS> (readonly)
127 128 129 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 127 def ics @ics end |
#id ⇒ String? (readonly)
49 50 51 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 49 def id @id end |
#keyword ⇒ Array<RelatonBib::LocalizedString> (readonly)
121 122 123 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 121 def keyword @keyword end |
#language ⇒ Array<String> (readonly)
Returns language Iso639 code.
76 77 78 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 76 def language @language end |
#license ⇒ Array<Strig> (readonly)
109 110 111 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 109 def license @license end |
#link ⇒ Array<RelatonBib::TypedUri> (readonly)
58 59 60 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 58 def link @link end |
#medium ⇒ RelatonBib::Medium? (readonly)
100 101 102 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 100 def medium @medium end |
#place ⇒ Array<RelatonBib::Place> (readonly)
103 104 105 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 103 def place @place end |
#relation ⇒ RelatonBib::DocRelationCollection (readonly)
94 95 96 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 94 def relation @relation end |
#script ⇒ Array<String> (readonly)
Returns script Iso15924 code.
79 80 81 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 79 def script @script end |
#series ⇒ Array<RelatonBib::Series> (readonly)
97 98 99 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 97 def series @series end |
#size ⇒ RelatonBib::BibliographicSize? (readonly)
133 134 135 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 133 def size @size end |
#status ⇒ RelatonBib::DocumentStatus? (readonly)
88 89 90 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 88 def status @status end |
#structuredidentifier ⇒ RelatonBib::StructuredIdentifierCollection (readonly)
130 131 132 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 130 def structuredidentifier @structuredidentifier end |
#subdoctype ⇒ String? (readonly)
49 50 51 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 49 def subdoctype @subdoctype end |
#title(lang: nil) ⇒ RelatonIsoBib::TypedTitleStringCollection (readonly)
|
# File 'lib/relaton_bib/bibliographic_item.rb', line 54
|
#type ⇒ String? (readonly)
49 50 51 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 49 def type @type end |
#validity ⇒ RelatonBib:Validity? (readonly)
115 116 117 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 115 def validity @validity end |
#version ⇒ Array<RelatonBib::BibliographicItem::Version> (readonly)
70 71 72 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 70 def version @version end |
Class Method Details
.from_hash(hash) ⇒ RelatonBipm::BipmBibliographicItem
309 310 311 312 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 309 def self.from_hash(hash) item_hash = Object.const_get(name.split("::")[0])::HashConverter.hash_to_bib(hash) new(**item_hash) end |
Instance Method Details
#deep_clone ⇒ Object
477 478 479 480 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 477 def deep_clone dump = Marshal.dump self Marshal.load dump # rubocop:disable Security/MarshalLoad end |
#disable_id_attribute ⇒ Object
482 483 484 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 482 def disable_id_attribute @id_attribute = false end |
#makeid(identifier, attribute) ⇒ String
327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 327 def makeid(identifier, attribute) return nil if attribute && !@id_attribute identifier ||= @docidentifier.reject { |i| i.type == "DOI" }[0] return unless identifier # contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/' # idstr = "#{contribs}#{delim}#{id.project_number}" # idstr = id.project_number.to_s idstr = identifier.id.gsub(/[:\/]/, "-").gsub(/\s/, "") # if id.part_number&.size&.positive? then idstr += "-#{id.part_number}" idstr.strip end |
#revdate ⇒ String?
If revision_date exists then returns it else returns published date or nil
532 533 534 535 536 537 538 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 532 def revdate # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity @revdate ||= if (v = version.detect &:revision_date) v.revision_date else date.detect { |d| d.type == "published" }&.on&.to_s end end |
#schema ⇒ String
Fetch schema version
294 295 296 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 294 def schema @schema ||= schema_versions["relaton-models"] end |
#schema_versions ⇒ Hash{String=>String}
Read schema versions from file
303 304 305 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 303 def schema_versions JSON.parse File.read(File.join(__dir__, "../../grammars/versions.json")) end |
#shortref(identifier, **opts) ⇒ String
346 347 348 349 350 351 352 353 354 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 346 def shortref(identifier, **opts) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity pubdate = date.select { |d| d.type == "published" } year = if opts[:no_year] || pubdate.empty? then "" else ":#{pubdate&.first&.on(:year)}" end year += ": All Parts" if opts[:all_parts] || @all_parts "#{makeid(identifier, false)}#{year}" end |
#to_all_parts ⇒ Object
remove title part components and abstract
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 487 def to_all_parts # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity me = deep_clone me.disable_id_attribute me.relation << DocumentRelation.new(type: "instanceOf", bibitem: self) me.language.each do |l| me.title.delete_title_part! ttl = me.title.select do |t| t.type != "main" && t.title.language&.include?(l) end next if ttl.empty? tm_en = ttl.map { |t| t.title.content }.join " – " me.title.detect do |t| t.type == "main" && t.title.language&.include?(l) end&.title&.content = tm_en end me.abstract = [] me.docidentifier.each(&:remove_part) me.docidentifier.each(&:all_parts) me.structuredidentifier.remove_part me.structuredidentifier.all_parts me.docidentifier.each &:remove_date me.structuredidentifier&.remove_date me.all_parts = true me end |
#to_asciibib(prefix = "") ⇒ String
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 542 def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity pref = prefix.empty? ? prefix : "#{prefix}." out = prefix.empty? ? "[%bibitem]\n== {blank}\n" : "" out += "#{pref}id:: #{id}\n" if id out += "#{pref}fetched:: #{fetched}\n" if fetched title.each { |t| out += t.to_asciibib(prefix, title.size) } out += "#{pref}type:: #{type}\n" if type docidentifier.each do |di| out += di.to_asciibib prefix, docidentifier.size end out += "#{pref}docnumber:: #{docnumber}\n" if docnumber out += edition.to_asciibib(prefix) if edition language.each { |l| out += "#{pref}language:: #{l}\n" } script.each { |s| out += "#{pref}script:: #{s}\n" } version.each { |v| out += v.to_asciibib prefix, version.size } biblionote&.each { |b| out += b.to_asciibib prefix, biblionote.size } out += status.to_asciibib prefix if status date.each { |d| out += d.to_asciibib prefix, date.size } abstract.each do |a| out += a.to_asciibib "#{pref}abstract", abstract.size end copyright.each { |c| out += c.to_asciibib prefix, copyright.size } link.each { |l| out += l.to_asciibib prefix, link.size } out += medium.to_asciibib prefix if medium place.each { |pl| out += pl.to_asciibib prefix, place.size } extent.each { |ex| out += ex.to_asciibib "#{pref}extent", extent.size } out += size.to_asciibib pref if size accesslocation.each { |al| out += "#{pref}accesslocation:: #{al}\n" } classification.each do |cl| out += cl.to_asciibib prefix, classification.size end out += validity.to_asciibib prefix if validity contributor.each do |c| out += c.to_asciibib "contributor.*", contributor.size end out += relation.to_asciibib prefix if relation series.each { |s| out += s.to_asciibib prefix, series.size } out += "#{pref}doctype:: #{doctype}\n" if doctype out += "#{pref}subdoctype:: #{subdoctype}\n" if subdoctype out += "#{pref}formattedref:: #{formattedref}\n" if formattedref keyword.each { |kw| out += kw.to_asciibib "#{pref}keyword", keyword.size } out += editorialgroup.to_asciibib prefix if editorialgroup ics.each { |i| out += i.to_asciibib prefix, ics.size } out += structuredidentifier.to_asciibib prefix if structuredidentifier out end |
#to_bibtex(bibtex = nil) ⇒ String
Reander BibTeX
444 445 446 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 444 def to_bibtex(bibtex = nil) Renderer::BibtexBuilder.build(self, bibtex).to_s end |
#to_bibxml(builder = nil, include_keywords: false) ⇒ String, Nokogiri::XML::Builder::NodeBuilder
Render BibXML (RFC)
380 381 382 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 380 def to_bibxml(builder = nil, include_keywords: false) Renderer::BibXML.new(self).render builder: builder, include_keywords: include_keywords end |
#to_citeproc(bibtex = nil) ⇒ Hash
Render citeproc
455 456 457 458 459 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 455 def to_citeproc(bibtex = nil) Renderer::BibtexBuilder.build(self, bibtex).to_citeproc.map do |cp| cp.transform_keys(&:to_s) end end |
#to_hash(embedded: false) ⇒ Hash
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 385 def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity hash = {} hash["schema-version"] = schema unless hash["id"] = id if id hash["title"] = title.to_hash if title&.any? hash["link"] = single_element_array(link) if link&.any? hash["type"] = type if type hash["docid"] = single_element_array(docidentifier) if docidentifier&.any? hash["docnumber"] = docnumber if docnumber hash["date"] = single_element_array(date) if date&.any? if contributor&.any? hash["contributor"] = single_element_array(contributor) end hash["edition"] = edition.to_hash if edition hash["version"] = version.map &:to_hash if version.any? hash["revdate"] = revdate if revdate hash["biblionote"] = single_element_array(biblionote) if biblionote&.any? hash["language"] = single_element_array(language) if language&.any? hash["script"] = single_element_array(script) if script&.any? hash["formattedref"] = formattedref.to_hash if formattedref hash["abstract"] = single_element_array(abstract) if abstract&.any? hash["docstatus"] = status.to_hash if status hash["copyright"] = single_element_array(copyright) if copyright&.any? hash["relation"] = single_element_array(relation) if relation&.any? hash["series"] = single_element_array(series) if series&.any? hash["medium"] = medium.to_hash if medium hash["place"] = single_element_array(place) if place&.any? hash["extent"] = single_element_array(extent) if extent&.any? hash["size"] = size.to_hash if size&.any? if accesslocation&.any? hash["accesslocation"] = single_element_array(accesslocation) end if classification&.any? hash["classification"] = single_element_array(classification) end hash["validity"] = validity.to_hash if validity hash["fetched"] = fetched.to_s if fetched hash["keyword"] = single_element_array(keyword) if keyword&.any? hash["license"] = single_element_array(license) if license&.any? hash["doctype"] = doctype if doctype hash["subdoctype"] = subdoctype if subdoctype if editorialgroup&.presence? hash["editorialgroup"] = editorialgroup.to_hash end hash["ics"] = single_element_array ics if ics.any? if structuredidentifier&.presence? hash["structuredidentifier"] = structuredidentifier.to_hash end hash["ext"] = { "schema-version" => ext_schema } if ! && respond_to?(:ext_schema) && ext_schema hash 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
518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 518 def to_most_recent_reference me = deep_clone disable_id_attribute me.relation << DocumentRelation.new(type: "instanceOf", bibitem: self) me.abstract = [] me.date = [] me.docidentifier.each &:remove_date me.structuredidentifier&.remove_date me.id&.sub!(/-[12]\d\d\d/, "") me end |
#to_xml(**opts, &block) ⇒ String
Returns XML.
362 363 364 365 366 367 368 369 370 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 362 def to_xml(**opts, &block) if opts[:builder] render_xml(**opts, &block) else Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| render_xml builder: xml, **opts, &block end.doc.root.to_xml end end |
#url(type = :src) ⇒ String?
469 470 471 |
# File 'lib/relaton_bib/bibliographic_item.rb', line 469 def url(type = :src) @link.detect { |s| s.type == type.to_s }&.content&.to_s end |