Class: RelatonBib::Contributor

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

Overview

Contributor.

Direct Known Subclasses

Organization, Person

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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



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

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

Instance Attribute Details

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



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

def contact
  @contact
end

#uriURI (readonly)



125
126
127
# File 'lib/relaton_bib/contributor.rb', line 125

def uri
  @uri
end

Instance Method Details

#to_hashHash



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

def to_hash
  hash = {}
  hash[:url] = uri.to_s if uri
  hash[:contact] = contact.map(&:to_hash) if contact&.any?
  hash
end

#to_xml(builder) ⇒ Object



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

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

#urlString

Returns url.



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

def url
  @uri.to_s
end