Class: RelatonBib::Contributor
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(url: nil, contact: []) ⇒ Contributor
Returns a new instance of Contributor.
191
192
193
194
|
# File 'lib/relaton_bib/contributor.rb', line 191
def initialize(url: nil, contact: [])
@uri = URI url if url
@contact = contact
end
|
Instance Attribute Details
187
188
189
|
# File 'lib/relaton_bib/contributor.rb', line 187
def contact
@contact
end
|
#uri ⇒ URI
184
185
186
|
# File 'lib/relaton_bib/contributor.rb', line 184
def uri
@uri
end
|
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/relaton_bib/contributor.rb', line 217
def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : "#{prefix}."
out = ""
out += "#{pref}url:: #{uri}\n" if uri
addr = contact.select { |c| c.is_a? RelatonBib::Address }
addr.each { |ct| out += ct.to_asciibib prefix, addr.size }
cont = contact.select { |c| c.is_a? RelatonBib::Contact }
cont.each { |ct| out += ct.to_asciibib prefix, cont.size }
out
end
|
#to_hash ⇒ Hash
208
209
210
211
212
213
|
# File 'lib/relaton_bib/contributor.rb', line 208
def to_hash
hash = {}
hash["url"] = uri.to_s if uri
hash["contact"] = single_element_array(contact) if contact&.any?
hash
end
|
#to_xml(builder) ⇒ Object
203
204
205
|
# File 'lib/relaton_bib/contributor.rb', line 203
def to_xml(builder)
contact.each { |contact| contact.to_xml builder }
end
|
#url ⇒ String
198
199
200
|
# File 'lib/relaton_bib/contributor.rb', line 198
def url
@uri.to_s
end
|