Class: Datacite::Mapping::Description

Inherits:
Object
  • Object
show all
Includes:
XML::Mapping
Defined in:
lib/datacite/mapping/description.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value:, language: nil) ⇒ Description

Initializes a new Datacite::Mapping::Description

Parameters:

  • language (String, nil) (defaults to: nil)

    an IETF BCP 47, ISO 639-1 language code identifying the language.

  • type (DescriptionType)

    the description type.

  • value (String)

    the description itself. See Datacite::Mapping::Description for notes on special handling of <br/> tags.



89
90
91
92
93
# File 'lib/datacite/mapping/description.rb', line 89

def initialize(type:, value:, language: nil)
  self.language = language
  self.type = type
  self.value = value
end

Instance Attribute Details

#languageString

Returns an IETF BCP 47, ISO 639-1 language code identifying the language.

Returns:

  • (String)

    an IETF BCP 47, ISO 639-1 language code identifying the language.



108
# File 'lib/datacite/mapping/description.rb', line 108

text_node :language, '@xml:lang', default_value: nil

#typeDescriptionType

Returns the description type.

Returns:



112
# File 'lib/datacite/mapping/description.rb', line 112

typesafe_enum_node :type, '@descriptionType', class: DescriptionType

#valueString

Returns the description itself. See Datacite::Mapping::Description for notes on special handling of <br/> tags.

Returns:



117
# File 'lib/datacite/mapping/description.rb', line 117

break_preserving_value_node :value, 'node()'