Class: IsoBibItem::DocumentRelation

Inherits:
Object
  • Object
show all
Defined in:
lib/iso_bib_item/document_relation_collection.rb

Overview

Documett relation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DocumentRelation.

Parameters:

  • type (String)
  • identifier (String)


77
78
79
80
81
82
83
84
# File 'lib/iso_bib_item/document_relation_collection.rb', line 77

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

Instance Attribute Details

#bib_localityArray<IsoBibItem::BibItemLocality> (readonly)



73
74
75
# File 'lib/iso_bib_item/document_relation_collection.rb', line 73

def bib_locality
  @bib_locality
end

#bibitemIsoBibItem::BibliographicItem (readonly)



70
71
72
# File 'lib/iso_bib_item/document_relation_collection.rb', line 70

def bibitem
  @bibitem
end

#identifierString (readonly)

Returns:

  • (String)


67
68
69
# File 'lib/iso_bib_item/document_relation_collection.rb', line 67

def identifier
  @identifier
end

#typeString (readonly)

Returns:

  • (String)


64
65
66
# File 'lib/iso_bib_item/document_relation_collection.rb', line 64

def type
  @type
end

#urlString (readonly)

Returns:

  • (String)


67
68
69
# File 'lib/iso_bib_item/document_relation_collection.rb', line 67

def url
  @url
end

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/iso_bib_item/document_relation_collection.rb', line 87

def to_xml(builder)
  builder.relation(type: type) do
    if @bibitem.nil?
      builder.bibitem do
        builder.formattedref identifier
        # builder.docidentifier identifier
      end
      bib_locality.each do |l|
        l.to_xml builder
      end
    else
      @bibitem.to_xml(builder, {})
    end
    # builder.url url
  end
end