Class: RelatonBib::Contributor
- Inherits:
-
Object
- Object
- RelatonBib::Contributor
- Defined in:
- lib/relaton_bib/contributor.rb
Overview
Contributor.
Direct Known Subclasses
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.
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
#contact ⇒ Array<RelatonBib::Address, RelatonBib::Contact> (readonly)
128 129 130 |
# File 'lib/relaton_bib/contributor.rb', line 128 def contact @contact end |
#uri ⇒ URI (readonly)
125 126 127 |
# File 'lib/relaton_bib/contributor.rb', line 125 def uri @uri end |
Instance Method Details
#to_hash ⇒ Hash
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 |
#url ⇒ String
Returns url.
139 140 141 |
# File 'lib/relaton_bib/contributor.rb', line 139 def url @uri.to_s end |