Sha256: baff4d0f9a4199e4e1006214ae246261599bd31807e54e11e1740b64e3434810

Contents?: true

Size: 1.36 KB

Versions: 10

Compression:

Stored size: 1.36 KB

Contents

require 'mspire/mzml/file_content'
require 'mspire/mzml/source_file'
require 'mspire/mzml/contact'

module Mspire
  class Mzml
    class FileDescription

      # a summary of the different types of spectra, must be present
      attr_accessor :file_content

      # may or may not be present
      attr_accessor :source_files

      # zero to many (just listed in the singular, not enclosed in a list)
      #
      #     <contact>
      #     </contact>
      #     <contact>
      #     </contact>
      attr_accessor :contacts

      # hands the user the object if given a block
      def initialize(file_content=nil, source_files=[], contacts=[], &block)
        @file_content, @source_files, @contacts = file_content, source_files, contacts
        block.call(self) if block
        #raise ArgumentError, "FileDescription must have file_content" unless @file_content
      end

      def self.from_xml(xml)
        self.new
      end

      def to_xml(builder)
        builder.fileDescription do |fd_n|
          @file_content.to_xml(fd_n)
          if source_files.size > 0
            fd_n.sourceFileList(count: source_files.size) do |sf_n|
              source_files.each do |sf|
                sf.to_xml(sf_n)
              end
            end
          end
          contacts.each do |contact|
            contact.to_xml(fd_n)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mspire-0.7.18 lib/mspire/mzml/file_description.rb
mspire-0.7.17 lib/mspire/mzml/file_description.rb
mspire-0.7.13 lib/mspire/mzml/file_description.rb
mspire-0.7.12 lib/mspire/mzml/file_description.rb
mspire-0.7.11 lib/mspire/mzml/file_description.rb
mspire-0.7.10 lib/mspire/mzml/file_description.rb
mspire-0.7.9 lib/mspire/mzml/file_description.rb
mspire-0.7.8 lib/mspire/mzml/file_description.rb
mspire-0.7.7 lib/mspire/mzml/file_description.rb
mspire-0.7.6 lib/mspire/mzml/file_description.rb