Sha256: 99c24efb3c44815ad2b8c2207be4bc6ac46a68ae0711d2c0b5119c60ea224d7d

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

module RelatonBib
  # Version
  class BibliographicItem
    class Version
      # @return [String, NilClass]
      attr_reader :revision_date

      # @return [Array<String>]
      attr_reader :draft

      # @param revision_date [String, NilClass]
      # @param draft [Array<String>]
      def initialize(revision_date = nil, draft = [])
        @revision_date = revision_date
        @draft         = draft
      end

      # @param builder [Nokogiri::XML::Builder]
      def to_xml(builder)
        builder.version do
          builder.revision_date revision_date if revision_date
          draft.each { |d| builder.draft d }
        end
      end

      # @return [Hash]
      def to_hash
        hash = {}
        hash[:revision_date] = revision_date if revision_date
        hash[:draft] = draft if draft&.any?
        hash
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-bib-0.3.4 lib/relaton_bib/biblio_version.rb