# frozen_string_literal: true require 'iso_bib_item/person' # Isobib module module IsoBibItem # Contributor's role. class ContributorRole # @return [Array] attr_reader :description # @return [ContributorRoleType] attr_reader :type # @param type [String] allowed types "author", "editor", # "cartographer", "publisher" # @param description [Array] def initialize(type, description = []) @type = type @description = description.map { |d| FormattedString.new d } end def to_xml(builder) builder.role(type: type) do description.each do |d| builder.description { |desc| d.to_xml(desc) } end end end end # Contribution info. class ContributionInfo # @return [Array] attr_reader :role # @return # [IsoBibItem::Person, IsoBibItem::Organization, # IsoBibItem::IsoProjectGroup] attr_reader :entity # @param entity [IsoBibItem::Person, IsoBibItem::Organization, # IsoBibItem::IsoProjectGroup] # @param role [Array] def initialize(entity:, role: ['publisher']) @entity = entity @role = role.map { |r| ContributorRole.new(r) } end def to_xml(builder) entity.to_xml builder end end end