Class: RelatonBib::Affiliation
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/contributor.rb
Overview
Affiliation.
Constant Summary
Constants included from RelatonBib
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: []) ⇒ Affiliation
constructor
A new instance of Affiliation.
- #to_asciibib(prefix = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Methods included from RelatonBib
Constructor Details
#initialize(organization:, name: nil, description: []) ⇒ Affiliation
Returns a new instance of Affiliation.
126 127 128 129 130 |
# File 'lib/relaton_bib/contributor.rb', line 126 def initialize(organization:, name: nil, description: []) @name = name @organization = organization @description = description end |
Instance Attribute Details
#description ⇒ Array<RelatonBib::FormattedString> (readonly)
118 119 120 |
# File 'lib/relaton_bib/contributor.rb', line 118 def description @description end |
#name ⇒ RelatonBib::LocalizedString, NilClass (readonly)
115 116 117 |
# File 'lib/relaton_bib/contributor.rb', line 115 def name @name end |
#organization ⇒ RelatonBib::Organization (readonly)
121 122 123 |
# File 'lib/relaton_bib/contributor.rb', line 121 def organization @organization end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ String
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/relaton_bib/contributor.rb', line 154 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : prefix + "." out = count > 1 ? "#{pref}affiliation::\n" : "" out += name.to_asciibib "#{pref}affiliation.name" if name description.each do |d| out += d.to_asciibib "#{pref}affiliation.description", description.size end out += organization.to_asciibib "#{pref}affiliation.*" out end |
#to_hash ⇒ Hash
142 143 144 145 146 147 148 149 |
# File 'lib/relaton_bib/contributor.rb', line 142 def to_hash hash = organization.to_hash hash["name"] = name.to_hash if name if description&.any? hash["description"] = single_element_array(description) end hash end |
#to_xml(builder) ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/relaton_bib/contributor.rb', line 133 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 |