Class: IsoBibItem::Organization
- Inherits:
-
Contributor
- Object
- Contributor
- IsoBibItem::Organization
- Defined in:
- lib/iso_bib_item/organization.rb
Overview
Organization.
Instance Attribute Summary collapse
- #abbreviation ⇒ IsoBibItem::LocalizedString readonly
- #identifiers ⇒ Array<IsoBibItem::OrgIdentifier> readonly
- #name ⇒ IsoBibItem::LocalizedString readonly
Attributes inherited from Contributor
Instance Method Summary collapse
- #hash2locstr(name) ⇒ Object
-
#initialize(name:, abbreviation: nil, url: nil, identifiers: []) ⇒ Organization
constructor
A new instance of Organization.
- #to_xml(builder) ⇒ Object
Methods inherited from Contributor
Constructor Details
#initialize(name:, abbreviation: nil, url: nil, identifiers: []) ⇒ Organization
Returns a new instance of Organization.
50 51 52 53 54 55 |
# File 'lib/iso_bib_item/organization.rb', line 50 def initialize(name:, abbreviation: nil, url: nil, identifiers: []) super(url: url) @name = name.is_a?(Array) ? name.map { |n| hash2locstr(n) } : [hash2locstr(name)] @abbreviation = LocalizedString.new abbreviation @identifiers = identifiers end |
Instance Attribute Details
#abbreviation ⇒ IsoBibItem::LocalizedString (readonly)
37 38 39 |
# File 'lib/iso_bib_item/organization.rb', line 37 def abbreviation @abbreviation end |
#identifiers ⇒ Array<IsoBibItem::OrgIdentifier> (readonly)
40 41 42 |
# File 'lib/iso_bib_item/organization.rb', line 40 def identifiers @identifiers end |
#name ⇒ IsoBibItem::LocalizedString (readonly)
34 35 36 |
# File 'lib/iso_bib_item/organization.rb', line 34 def name @name end |
Instance Method Details
#hash2locstr(name) ⇒ Object
42 43 44 |
# File 'lib/iso_bib_item/organization.rb', line 42 def hash2locstr(name) name.is_a?(Hash) ? LocalizedString.new(name[:content], name[:language], name[:script]) : LocalizedString.new(name) end |
#to_xml(builder) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/iso_bib_item/organization.rb', line 58 def to_xml(builder) builder.organization do name.each do |n| builder.name { |b| n.to_xml b } end builder.abbreviation { |a| abbreviation.to_xml a } if abbreviation&.to_s builder.uri uri.to_s if uri identifiers.each { |identifier| identifier.to_xml builder } super end end |