Class: RelatonBib::Affilation
- Inherits:
-
Object
- Object
- RelatonBib::Affilation
- Defined in:
- lib/relaton_bib/contributor.rb
Overview
Affilation.
Instance Attribute Summary collapse
- #description ⇒ Array<RelatonBib::FormattedString> readonly
- #name ⇒ RelatonBib::LocalizedString, NilClass readonly
- #organization ⇒ RelatonBib::Organization readonly
Instance Method Summary collapse
-
#initialize(organization:, name: nil, description: []) ⇒ Affilation
constructor
A new instance of Affilation.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(organization:, name: nil, description: []) ⇒ Affilation
Returns a new instance of Affilation.
98 99 100 101 102 |
# File 'lib/relaton_bib/contributor.rb', line 98 def initialize(organization:, name: nil, description: []) @name = name @organization = organization @description = description end |
Instance Attribute Details
#description ⇒ Array<RelatonBib::FormattedString> (readonly)
90 91 92 |
# File 'lib/relaton_bib/contributor.rb', line 90 def description @description end |
#name ⇒ RelatonBib::LocalizedString, NilClass (readonly)
87 88 89 |
# File 'lib/relaton_bib/contributor.rb', line 87 def name @name end |
#organization ⇒ RelatonBib::Organization (readonly)
93 94 95 |
# File 'lib/relaton_bib/contributor.rb', line 93 def organization @organization end |
Instance Method Details
#to_hash ⇒ Hash
114 115 116 117 118 119 |
# File 'lib/relaton_bib/contributor.rb', line 114 def to_hash hash = organization.to_hash hash[:name] = name.to_hash if name hash[:description] = description.map(&:to_hash) if description&.any? hash end |
#to_xml(builder) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/relaton_bib/contributor.rb', line 105 def to_xml(builder) builder.affiliation do builder.name { name.to_xml builder } if name description.each { |d| builder.description { d.to_xml builder } } organization.to_xml builder end end |