Class: RelatonBib::Organization
- Inherits:
-
Contributor
- Object
- Contributor
- RelatonBib::Organization
- Defined in:
- lib/relaton_bib/organization.rb
Overview
Organization.
Instance Attribute Summary collapse
- #abbreviation ⇒ RelatonBib::LocalizedString readonly
- #identifiers ⇒ Array<RelatonBib::OrgIdentifier> readonly
- #name ⇒ RelatonBib::LocalizedString readonly
- #subdivision ⇒ RelatonBib::LocalizedString readonly
Attributes inherited from Contributor
Instance Method Summary collapse
- #hash2locstr(name) ⇒ Object
-
#initialize(**args) ⇒ Organization
constructor
A new instance of Organization.
- #to_xml(builder) ⇒ Object
Methods inherited from Contributor
Constructor Details
#initialize(**args) ⇒ Organization
Returns a new instance of Organization.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/relaton_bib/organization.rb', line 63 def initialize(**args) raise ArgumentError, "missing keyword: name" unless args[:name] super(url: args[:url], contacts: args.fetch(:contacts, [])) @name = if args[:name].is_a?(Array) args[:name].map { |n| hash2locstr(n) } else [hash2locstr(args[:name])] end @abbreviation = if args[:abbreviation].is_a?(String) LocalizedString.new(args[:abbreviation]) else args[:abbreviation] end @subdivision = if args[:subdivision].is_a?(String) LocalizedString.new(args[:subdivision]) else args[:subdivision] end @identifiers = args.fetch(:identifiers, []) end |
Instance Attribute Details
#abbreviation ⇒ RelatonBib::LocalizedString (readonly)
45 46 47 |
# File 'lib/relaton_bib/organization.rb', line 45 def abbreviation @abbreviation end |
#identifiers ⇒ Array<RelatonBib::OrgIdentifier> (readonly)
51 52 53 |
# File 'lib/relaton_bib/organization.rb', line 51 def identifiers @identifiers end |
#name ⇒ RelatonBib::LocalizedString (readonly)
42 43 44 |
# File 'lib/relaton_bib/organization.rb', line 42 def name @name end |
#subdivision ⇒ RelatonBib::LocalizedString (readonly)
48 49 50 |
# File 'lib/relaton_bib/organization.rb', line 48 def subdivision @subdivision end |
Instance Method Details
#hash2locstr(name) ⇒ Object
53 54 55 |
# File 'lib/relaton_bib/organization.rb', line 53 def hash2locstr(name) name.is_a?(Hash) ? LocalizedString.new(name[:content], name[:language], name[:script]) : LocalizedString.new(name) end |
#to_xml(builder) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/relaton_bib/organization.rb', line 90 def to_xml(builder) builder.organization do name.each do |n| builder.name { |b| n.to_xml b } end builder.subdivision { |s| subdivision.to_xml s } if subdivision builder.abbreviation { |a| abbreviation.to_xml a } if abbreviation builder.uri url if uri identifiers.each { |identifier| identifier.to_xml builder } super end end |