Class: RelatonBib::Contributor

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

Overview

Contributor.

Direct Known Subclasses

Organization, Person

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(url: nil, contact: []) ⇒ Contributor

Returns a new instance of Contributor.

Parameters:



136
137
138
139
# File 'lib/relaton_bib/contributor.rb', line 136

def initialize(url: nil, contact: [])
  @uri = URI url if url
  @contact = contact
end

Instance Attribute Details

#contactArray<RelatonBib::Address, RelatonBib::Contact> (readonly)



132
133
134
# File 'lib/relaton_bib/contributor.rb', line 132

def contact
  @contact
end

#uriURI (readonly)

Returns:

  • (URI)


129
130
131
# File 'lib/relaton_bib/contributor.rb', line 129

def uri
  @uri
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


153
154
155
156
157
158
# File 'lib/relaton_bib/contributor.rb', line 153

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



148
149
150
# File 'lib/relaton_bib/contributor.rb', line 148

def to_xml(builder)
  contact.each { |contact| contact.to_xml builder }
end

#urlString

Returns url.

Returns:

  • (String)


143
144
145
# File 'lib/relaton_bib/contributor.rb', line 143

def url
  @uri.to_s
end