Class: RelatonBib::Affilation
- Inherits:
-
Object
- Object
- RelatonBib::Affilation
show all
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/contributor.rb
Overview
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.
101
102
103
104
105
|
# File 'lib/relaton_bib/contributor.rb', line 101
def initialize(organization:, name: nil, description: [])
@name = name
@organization = organization
@description = description
end
|
Instance Attribute Details
93
94
95
|
# File 'lib/relaton_bib/contributor.rb', line 93
def description
@description
end
|
90
91
92
|
# File 'lib/relaton_bib/contributor.rb', line 90
def name
@name
end
|
96
97
98
|
# File 'lib/relaton_bib/contributor.rb', line 96
def organization
@organization
end
|
Instance Method Details
#to_hash ⇒ Hash
117
118
119
120
121
122
|
# File 'lib/relaton_bib/contributor.rb', line 117
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
108
109
110
111
112
113
114
|
# File 'lib/relaton_bib/contributor.rb', line 108
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
|