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

parse_date

Constructor Details

#initialize(url: nil, contact: []) ⇒ Contributor

Returns a new instance of Contributor.

Parameters:



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

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

Instance Attribute Details

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



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

def contact
  @contact
end

#uriURI (readonly)

Returns:

  • (URI)


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

def uri
  @uri
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


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

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



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

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

#urlString

Returns url.

Returns:

  • (String)


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

def url
  @uri.to_s
end