Class: RelatonBib::ContributorRole
- Inherits:
-
Object
- Object
- RelatonBib::ContributorRole
- Defined in:
- lib/relaton_bib/contribution_info.rb
Overview
Contributor’s role.
Constant Summary collapse
- TYPES =
%w[author performer publisher editor adapter translator distributor ].freeze
Instance Attribute Summary collapse
- #description ⇒ Array<RelatonBib::FormattedString> readonly
- #type ⇒ ContributorRoleType readonly
Instance Method Summary collapse
-
#initialize(*args) ⇒ ContributorRole
constructor
A new instance of ContributorRole.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(*args) ⇒ ContributorRole
Returns a new instance of ContributorRole.
36 37 38 39 40 41 42 43 |
# File 'lib/relaton_bib/contribution_info.rb', line 36 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 |
Instance Attribute Details
#description ⇒ Array<RelatonBib::FormattedString> (readonly)
28 29 30 |
# File 'lib/relaton_bib/contribution_info.rb', line 28 def description @description end |
#type ⇒ ContributorRoleType (readonly)
31 32 33 |
# File 'lib/relaton_bib/contribution_info.rb', line 31 def type @type end |
Instance Method Details
#to_xml(builder) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/relaton_bib/contribution_info.rb', line 45 def to_xml(builder) builder.role(type: type) do description.each do |d| builder.description { |desc| d.to_xml(desc) } end end end |