Class: RelatonBib::ContributionInfo
- Inherits:
-
Object
- Object
- RelatonBib::ContributionInfo
- Defined in:
- lib/relaton_bib/contribution_info.rb
Overview
Contribution info.
Instance Attribute Summary collapse
-
#entity ⇒ Object
readonly
[RelatonBib::Person, RelatonBib::Organization].
- #role ⇒ Array<RelatonBib::ContributorRole> readonly
Instance Method Summary collapse
-
#initialize(entity:, role: [{ type: "publisher" }]) ⇒ ContributionInfo
constructor
A new instance of ContributionInfo.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(entity:, role: [{ type: "publisher" }]) ⇒ ContributionInfo
Returns a new instance of ContributionInfo.
61 62 63 64 |
# File 'lib/relaton_bib/contribution_info.rb', line 61 def initialize(entity:, role: [{ type: "publisher" }]) @entity = entity @role = role.map { |r| ContributorRole.new(**r) } end |
Instance Attribute Details
#entity ⇒ Object (readonly)
Returns [RelatonBib::Person, RelatonBib::Organization].
57 58 59 |
# File 'lib/relaton_bib/contribution_info.rb', line 57 def entity @entity end |
#role ⇒ Array<RelatonBib::ContributorRole> (readonly)
53 54 55 |
# File 'lib/relaton_bib/contribution_info.rb', line 53 def role @role end |
Instance Method Details
#to_hash ⇒ Hash
72 73 74 75 76 |
# File 'lib/relaton_bib/contribution_info.rb', line 72 def to_hash hash = entity.to_hash hash[:role] = role.map(&:to_hash) if role&.any? hash end |
#to_xml(builder) ⇒ Object
67 68 69 |
# File 'lib/relaton_bib/contribution_info.rb', line 67 def to_xml(builder) entity.to_xml builder end |