Class: RelatonBib::Contributor
- Inherits:
-
Object
- Object
- RelatonBib::Contributor
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/contributor.rb
Overview
Contributor.
Direct Known Subclasses
Constant Summary
Constants included from RelatonBib
Instance Attribute Summary collapse
- #contact ⇒ Array<RelatonBib::Address, RelatonBib::Contact> readonly
- #uri ⇒ URI readonly
Instance Method Summary collapse
-
#initialize(url: nil, contact: []) ⇒ Contributor
constructor
A new instance of Contributor.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
-
#url ⇒ String
Returns url.
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.
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
#contact ⇒ Array<RelatonBib::Address, RelatonBib::Contact> (readonly)
132 133 134 |
# File 'lib/relaton_bib/contributor.rb', line 132 def contact @contact end |
#uri ⇒ URI (readonly)
129 130 131 |
# File 'lib/relaton_bib/contributor.rb', line 129 def uri @uri end |
Instance Method Details
#to_hash ⇒ 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 |
#url ⇒ String
Returns url.
143 144 145 |
# File 'lib/relaton_bib/contributor.rb', line 143 def url @uri.to_s end |