Class: RelatonBib::DocumentRelation

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/document_relation.rb

Overview

Documett relation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, bibitem:, bib_locality: []) ⇒ DocumentRelation

Returns a new instance of DocumentRelation.

Parameters:



59
60
61
62
63
64
# File 'lib/relaton_bib/document_relation.rb', line 59

def initialize(type:, bibitem:, bib_locality: [])
  type = "obsoletes" if type == "Now withdrawn"
  @type         = type
  @bib_locality = bib_locality
  @bibitem      = bibitem
end

Instance Attribute Details

#bib_localityArray<RelatonBib::BibItemLocality> (readonly)

Returns:



54
55
56
# File 'lib/relaton_bib/document_relation.rb', line 54

def bib_locality
  @bib_locality
end

#bibitemRelatonBib::BibliographicItem (readonly)



51
52
53
# File 'lib/relaton_bib/document_relation.rb', line 51

def bibitem
  @bibitem
end

#typeString (readonly)

Returns:

  • (String)


45
46
47
# File 'lib/relaton_bib/document_relation.rb', line 45

def type
  @type
end

Instance Method Details

#to_xml(builder, **opts) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


67
68
69
70
71
72
73
74
75
76
# File 'lib/relaton_bib/document_relation.rb', line 67

def to_xml(builder, **opts)
  opts.delete :bibdata
  opts.delete :note
  builder.relation(type: type) do
    bibitem.to_xml(builder, **opts.merge(embedded: true))
    bib_locality.each do |l|
      l.to_xml builder
    end
  end
end