Class: RelatonBib::Affilation

Inherits:
Object
  • Object
show all
Includes:
RelatonBib
Defined in:
lib/relaton_bib/contributor.rb

Overview

Affilation.

Constant Summary

Constants included from RelatonBib

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RelatonBib

array, formattedref, hash_to_bib, localizedstring, localname, parse_date, symbolize, timestamp_hash

Constructor Details

#initialize(organization:, name: nil, description: []) ⇒ Affilation

Returns a new instance of Affilation.

Parameters:



100
101
102
103
104
# File 'lib/relaton_bib/contributor.rb', line 100

def initialize(organization:, name: nil, description: [])
  @name = name
  @organization = organization
  @description  = description
end

Instance Attribute Details

#descriptionArray<RelatonBib::FormattedString> (readonly)

Returns:



92
93
94
# File 'lib/relaton_bib/contributor.rb', line 92

def description
  @description
end

#nameRelatonBib::LocalizedString, NilClass (readonly)

Returns:



89
90
91
# File 'lib/relaton_bib/contributor.rb', line 89

def name
  @name
end

#organizationRelatonBib::Organization (readonly)



95
96
97
# File 'lib/relaton_bib/contributor.rb', line 95

def organization
  @organization
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


116
117
118
119
120
121
# File 'lib/relaton_bib/contributor.rb', line 116

def to_hash
  hash = organization.to_hash
  hash["name"] = name.to_hash if name
  hash["description"] = single_element_array(description) if description&.any?
  hash
end

#to_xml(builder) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/relaton_bib/contributor.rb', line 107

def to_xml(builder)
  builder.affiliation do
    builder.name { name.to_xml builder } if name
    description.each { |d| builder.description { d.to_xml builder } }
    organization.to_xml builder
  end
end