Sha256: 703bbe71622d93d805b0059794eccee18397e8760e7bd6c92e46ae7fcd0ac703

Contents?: true

Size: 950 Bytes

Versions: 6

Compression:

Stored size: 950 Bytes

Contents

require 'xml/mapping_extensions'

module Datacite
  module Mapping

    # Rights information for the {Resource}
    class Rights
      include XML::Mapping

      # @!attribute [rw] uri
      #   @return [URI, nil] a URI for the license. Optional.
      uri_node :uri, '@rightsURI', default_value: nil

      # @!attribute [rw] value
      #   @return [String] the rights statement. Cannot be empty or nil.
      text_node :value, 'text()'

      # Initializes a new {Rights} object
      #
      # @param uri [URI, nil] a URI for the license. Optional.
      # @param value [String] the rights statement. Cannot be empty or nil.
      def initialize(uri: nil, value:)
        self.uri = uri
        self.value = value
      end

      alias_method :_value=, :value=
      private :_value=

      def value=(v)
        fail ArgumentError, 'Value cannot be empty or nil' unless v && !v.empty?
        self._value = v.strip
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datacite-mapping-0.1.5 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.4 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.3 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.2 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.1 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.0 lib/datacite/mapping/rights.rb