Class: RelatonBib::Person
- Inherits:
-
Contributor
- Object
- Contributor
- RelatonBib::Person
- Defined in:
- lib/relaton_bib/person.rb
Overview
Person class.
Constant Summary
Constants included from RelatonBib
Instance Attribute Summary collapse
- #affiliation ⇒ Array<RelatonBib::Affiliation>
- #identifier ⇒ Array<RelatonBib::PersonIdentifier>
- #name ⇒ RelatonBib::FullName
Attributes inherited from Contributor
Instance Method Summary collapse
-
#initialize(name:, affiliation: [], contact: [], identifier: [], url: nil) ⇒ Person
constructor
A new instance of Person.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Methods inherited from Contributor
Methods included from RelatonBib
Constructor Details
#initialize(name:, affiliation: [], contact: [], identifier: [], url: nil) ⇒ Person
Returns a new instance of Person.
134 135 136 137 138 139 |
# File 'lib/relaton_bib/person.rb', line 134 def initialize(name:, affiliation: [], contact: [], identifier: [], url: nil) super(contact: contact, url: url) @name = name @affiliation = affiliation @identifier = identifier end |
Instance Attribute Details
#affiliation ⇒ Array<RelatonBib::Affiliation>
124 125 126 |
# File 'lib/relaton_bib/person.rb', line 124 def affiliation @affiliation end |
#identifier ⇒ Array<RelatonBib::PersonIdentifier>
127 128 129 |
# File 'lib/relaton_bib/person.rb', line 127 def identifier @identifier end |
#name ⇒ RelatonBib::FullName
121 122 123 |
# File 'lib/relaton_bib/person.rb', line 121 def name @name end |
Instance Method Details
#to_hash ⇒ Hash
152 153 154 155 156 157 |
# File 'lib/relaton_bib/person.rb', line 152 def to_hash hash = { "name" => name.to_hash } hash["affiliation"] = single_element_array(affiliation) if affiliation&.any? hash["identifier"] = single_element_array(identifier) if identifier&.any? { "person" => hash.merge(super) } end |
#to_xml(builder) ⇒ Object
142 143 144 145 146 147 148 149 |
# File 'lib/relaton_bib/person.rb', line 142 def to_xml(builder) builder.person do name.to_xml builder affiliation.each { |a| a.to_xml builder } identifier.each { |id| id.to_xml builder } contact.each { |contact| contact.to_xml builder } end end |