Sha256: a45d21df4db3e4b62e08fa1892555b6b1cc5e3748a7e070aae88f005e3d8ab52
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true 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, nil] an IETF BCP 47, ISO 639-1 language code identifying the language. # @param value [String] the subject itself. def initialize(scheme: nil, scheme_uri: nil, language: nil, value:) self.scheme = scheme self.scheme_uri = scheme_uri self.language = language self.value = value end def language=(value) @language = value&.strip end def value=(value) new_value = value&.strip raise ArgumentError, 'Value cannot be empty or nil' unless new_value && !new_value.empty? @value = new_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, nil] an IETF BCP 47, ISO 639-1 language code identifying the language. text_node :language, '@xml:lang', default_value: nil # @!attribute [rw] value # @return [String] the subject itself. text_node :value, 'text()' fallback_mapping :datacite_3, :_default end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
datacite-mapping-0.4.1 | lib/datacite/mapping/subject.rb |
datacite-mapping-0.4.0 | lib/datacite/mapping/subject.rb |