Sha256: 9ba2d661d736b95a10a631dcb7a7b73cd1ba9b219efeb37cae14a1ead742d80c

Contents?: true

Size: 884 Bytes

Versions: 8

Compression:

Stored size: 884 Bytes

Contents

require 'xml/mapping_extensions'

module Datacite
  module Mapping

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

      # 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

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

      # @!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()'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datacite-mapping-0.1.16 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.15 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.14 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.13 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.12 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.10 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.9 lib/datacite/mapping/rights.rb
datacite-mapping-0.1.7 lib/datacite/mapping/rights.rb