Sha256: 4b8af762a13e8923263ce767dc8ee9897350fe9897f46203768d9070344321d5

Contents?: true

Size: 973 Bytes

Versions: 3

Compression:

Stored size: 973 Bytes

Contents

require 'xml/mapping'
require 'xml/mapping_extensions'

module Stash
  module Wrapper
    # Mapping for `<st:version>`
    class Version
      include ::XML::Mapping
      numeric_node :version_number, 'version_number'
      date_node :date, 'date', zulu: true
      text_node :note, 'note', default_value: nil

      # Creates a new {Version}
      # @param number [Integer] the version number
      # @param date [Date] the date the new version was created
      # @param note [String, nil] the (optional) version note
      def initialize(number:, date:, note: nil)
        fail ArgumentError, "specified version number does not appear to be an integer: #{number || 'nil'}" unless number.respond_to?(:to_i) && number.to_i == number
        fail ArgumentError, "date does not appear to be a Date object: #{date || 'nil'}" unless date.respond_to?(:iso8601)
        self.version_number = number
        self.date = date
        self.note = note
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stash-wrapper-0.1.11.1 lib/stash/wrapper/version.rb
stash-wrapper-0.1.11 lib/stash/wrapper/version.rb
stash-wrapper-0.1.10 lib/stash/wrapper/version.rb