Sha256: 7b70ea3059084c346dcc8266f2b5f3d689ee60ef0d5aa3437b4c65fe3029d149
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require "relaton_bib/person" # RelatonBib module module RelatonBib # Contributor's role. class ContributorRole TYPES = %w[author performer publisher editor adapter translator distributor].freeze # @return [Array<RelatonBib::FormattedString>] attr_reader :description # @return [ContributorRoleType] attr_reader :type # @param type [String] allowed types "author", "editor", # "cartographer", "publisher" # @param description [Array<String>] def initialize(*args) @type = args.fetch 0 if type && !TYPES.include?(type) raise ArgumentError, %{Type "#{type}" is invalid.} end @description = args.fetch(1, []).map { |d| FormattedString.new content: d, format: nil } 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<RelatonBib::ContributorRole>] attr_reader :role # @return # [RelatonBib::Person, RelatonBib::Organization, # RelatonBib::IsoProjectGroup] attr_reader :entity # @param entity [RelatonBib::Person, RelatonBib::Organization, # RelatonBib::IsoProjectGroup] # @param role [Array<String>] 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
Version data entries
4 entries across 4 versions & 1 rubygems