Class: RelatonBib::Affiliation
Overview
Constant Summary
Constants included
from RelatonBib
VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from RelatonBib
array, format_date, parse_date, parse_yaml
Constructor Details
#initialize(organization:, name: nil, description: []) ⇒ Affiliation
Returns a new instance of Affiliation.
135
136
137
138
139
|
# File 'lib/relaton_bib/contributor.rb', line 135
def initialize(organization:, name: nil, description: [])
@name = name
@organization = organization
@description = description
end
|
Instance Attribute Details
127
128
129
|
# File 'lib/relaton_bib/contributor.rb', line 127
def description
@description
end
|
124
125
126
|
# File 'lib/relaton_bib/contributor.rb', line 124
def name
@name
end
|
130
131
132
|
# File 'lib/relaton_bib/contributor.rb', line 130
def organization
@organization
end
|
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ String
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/relaton_bib/contributor.rb', line 167
def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : "#{prefix}."
out = count > 1 ? "#{pref}affiliation::\n" : ""
out += name.to_asciibib "#{pref}affiliation.name" if name
description.each do |d|
out += d.to_asciibib "#{pref}affiliation.description", description.size
end
out += organization.to_asciibib "#{pref}affiliation.*"
out
end
|
#to_hash ⇒ Hash
155
156
157
158
159
160
161
162
|
# File 'lib/relaton_bib/contributor.rb', line 155
def to_hash
hash = organization.to_hash
hash["name"] = name.to_hash if name
if description&.any?
hash["description"] = single_element_array(description)
end
hash
end
|
#to_xml(**opts) ⇒ Object
144
145
146
147
148
149
150
151
152
|
# File 'lib/relaton_bib/contributor.rb', line 144
def to_xml(**opts) opts[:builder].affiliation do |builder|
builder.name { name.to_xml builder } if name
desc = description.select { |d| d.language&.include? opts[:lang] }
desc = description unless desc.any?
desc.each { |d| builder.description { d.to_xml builder } }
organization.to_xml(**opts)
end
end
|