Sha256: 48d61d0f99cd916dbfff1edd42878670bfc956683290eae59e8019ff14b9ace2

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require 'xml/mapping_extensions'
require 'stash/wrapper/embargo_type'

module Stash
  module Wrapper

    # Mapping class for `<st:embargo>`
    class Embargo
      include ::XML::Mapping

      typesafe_enum_node :type, 'type', class: EmbargoType
      text_node :period, 'period'
      date_node :start_date, 'start', zulu: true
      date_node :end_date, 'end', zulu: true

      # Creates a new {Embargo} object
      # @param type [EmbargoType] The embargo type
      # @param period [String] The embargo period
      # @param start_date [Date] The embargo start date
      # @param end_date [Date] The embargo end date
      def initialize(type:, period:, start_date:, end_date:)
        self.type = type
        self.period = period
        self.start_date = start_date
        self.end_date = end_date
      end

      # Creates a new `Embargo` instance of type {EmbargoType::NONE} with the current date as start and end.
      # @return [Embargo]
      def self.none
        today = Date.today
        new(type: EmbargoType::NONE, period: EmbargoType::NONE.value, start_date: today, end_date: today)
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stash-wrapper-0.1.9 lib/stash/wrapper/embargo.rb
stash-wrapper-0.1.8 lib/stash/wrapper/embargo.rb
stash-wrapper-0.1.7 lib/stash/wrapper/embargo.rb
stash-wrapper-0.1.6 lib/stash/wrapper/embargo.rb
stash-wrapper-0.1.5 lib/stash/wrapper/embargo.rb
stash-wrapper-0.1.4 lib/stash/wrapper/embargo.rb