Sha256: 05500d6f2bd14896f6a7881238aad268d158867e93cd046f80f97467a8d86b3c

Contents?: true

Size: 1.19 KB

Versions: 60

Compression:

Stored size: 1.19 KB

Contents

module RelatonBib
  # Version
  class BibliographicItem
    class Version
      include RelatonBib

      # @return [String, nil]
      attr_reader :revision_date, :draft

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

      # @param builder [Nokogiri::XML::Builder]
      def to_xml(builder)
        builder.version do
          builder.send(:"revision-date", revision_date) if revision_date
          builder.draft draft if draft
        end
      end

      # @return [Hash]
      def to_hash
        hash = {}
        hash["revision_date"] = revision_date if revision_date
        hash["draft"] = draft if draft
        hash
      end

      # @param prefix [String]
      # @return [String]
      def to_asciibib(prefix = "", count = 1)
        pref = prefix.empty? ? prefix : "#{prefix}."
        out = count > 1 ? "#{prefix}version::\n" : ""
        if revision_date
          out += "#{pref}version.revision_date:: #{revision_date}\n"
        end
        out += "#{pref}version.draft:: #{draft}\n" if draft
        out
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
relaton-bib-1.13.11 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.10 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.9 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.8 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.7 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.6 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.5 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.4 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.3 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.2 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.1 lib/relaton_bib/biblio_version.rb
relaton-bib-1.13.0 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.7 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.6 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.5 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.4 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.3 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.2 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.1 lib/relaton_bib/biblio_version.rb
relaton-bib-1.12.0 lib/relaton_bib/biblio_version.rb