class Datacite::Mapping::Description

A additional information that does not fit in the other more specific {Resource} attributes.

Note: In accordance with the DataCite spec, description text can be separated by HTML `<br/>` tags. The {Description} class will preserve these, but at the expense of converting escaped `<br/>` in text values to actual `<br/>` tags. For example, when reading the following tag:

<description xml:lang="en-us" descriptionType="Abstract">
  Line 1<br/>Line 2 containing escaped &lt;br/&gt; tag<br/>Line 3
</description>

the value will be returned as the string

"Line 1<br/>Line 2 containing escaped <br/> tag<br/>Line 3"

in which it is impossible to distinguish the escaped an un-escaped `<br/>`s. The value would thus be written back to XML as:

<description xml:lang="en-us" descriptionType="Abstract">
  Line 1<br/>Line 2 containing escaped <br/> tag<br/>Line 3
</description>

Other escaped HTML or XML tags will still be escaped when written back, and other un-escaped HTML and XML tags are of course not allowed.

Public Class Methods

new(language: nil, type:, value:) click to toggle source

Initializes a new {Description} @param language [String, nil] an IETF BCP 47, ISO 639-1 language code identifying the language. @param type [DescriptionType] the description type. @param value [String] the description itself. See {Description} for notes on special

handling of `<br/>` tags.
# File lib/datacite/mapping/description.rb, line 89
def initialize(language: nil, type:, value:)
  self.language = language
  self.type = type
  self.value = value
end

Public Instance Methods

language=(value) click to toggle source
# File lib/datacite/mapping/description.rb, line 95
def language=(value)
  @language = value&.strip
end
value=(a_value) click to toggle source
# File lib/datacite/mapping/description.rb, line 99
def value=(a_value)
  new_value = a_value&.strip
  raise ArgumentError, 'Value cannot be empty or nil' unless new_value && !new_value.empty?

  @value = new_value
end