Sha256: c5825acb904f9386f8d1277358b5f477ea21ecca8590a20b88a5ee60efa8f83c

Contents?: true

Size: 1.91 KB

Versions: 11

Compression:

Stored size: 1.91 KB

Contents

require 'xml/mapping'

module Datacite
  module Mapping

    # Subject, keyword, classification code, or key phrase describing the {Resource}.
    class Subject
      include XML::Mapping

      # Initializes a new {Subject}
      # @param scheme [String, nil] the subject scheme or classification code or authority if one is used. Optional.
      # @param scheme_uri [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
      # @param language [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
      #   It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
      # @param value [String] the subject itself.
      def initialize(scheme: nil, scheme_uri: nil, language: 'en', value:)
        self.scheme = scheme
        self.scheme_uri = scheme_uri
        self.language = language
        self.value = value
      end

      def language
        @language || 'en'
      end

      def language=(value)
        @language = value.strip if value
      end

      # @!attribute [rw] scheme
      #   @return [String, nil] the subject scheme or classification code or authority if one is used. Optional.
      text_node :scheme, '@subjectScheme', default_value: nil

      # @!attribute [rw] scheme_uri
      #   @return [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
      uri_node :scheme_uri, '@schemeURI', default_value: nil

      # @!attribute [rw] language
      #   @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
      #     It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
      text_node :language, '@xml:lang', default_value: nil

      # @!attribute [rw] value
      #   @return [String] the subject itself.
      text_node :value, 'text()'

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
datacite-mapping-0.1.17.2 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.17.1 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.17 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.16 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.15 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.14 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.13 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.12 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.10 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.9 lib/datacite/mapping/subject.rb
datacite-mapping-0.1.7 lib/datacite/mapping/subject.rb