Class: 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
Constructor Details
#initialize(url: nil, contact: []) ⇒ Contributor
Returns a new instance of Contributor.
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
#contact ⇒ Array<RelatonBib::Address, RelatonBib::Contact> (readonly)
133 134 135 |
# File 'lib/relaton_bib/contributor.rb', line 133 def contact @contact end |
#uri ⇒ URI (readonly)
130 131 132 |
# File 'lib/relaton_bib/contributor.rb', line 130 def uri @uri end |
Instance Method Details
#to_hash ⇒ 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 |
#url ⇒ String
Returns url.
144 145 146 |
# File 'lib/relaton_bib/contributor.rb', line 144 def url @uri.to_s end |