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, grammar_hash, parse_date, parse_yaml
Methods included from Config
#configuration, #configure
Constructor Details
#initialize(url: nil, contact: []) ⇒ Contributor
Returns a new instance of Contributor.
213
214
215
216
|
# File 'lib/relaton_bib/contributor.rb', line 213
def initialize(url: nil, contact: [])
@uri = URI url if url
@contact = contact
end
|
Instance Attribute Details
209
210
211
|
# File 'lib/relaton_bib/contributor.rb', line 209
def contact
@contact
end
|
#uri ⇒ URI
206
207
208
|
# File 'lib/relaton_bib/contributor.rb', line 206
def uri
@uri
end
|
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/relaton_bib/contributor.rb', line 239
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
230
231
232
233
234
235
|
# File 'lib/relaton_bib/contributor.rb', line 230
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
225
226
227
|
# File 'lib/relaton_bib/contributor.rb', line 225
def to_xml(builder)
contact.each { |contact| contact.to_xml builder }
end
|
#url ⇒ String
220
221
222
|
# File 'lib/relaton_bib/contributor.rb', line 220
def url
@uri.to_s
end
|