Sha256: 7b7e7dc892b3daac4dbf066d88637eac89e369a4756efe9ab3755f4622a16f73

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

require 'ms/mzml/file_content'
require 'ms/mzml/source_file'
require 'ms/mzml/contact'

module MS
  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 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

11 entries across 11 versions & 1 rubygems

Version Path
mspire-0.6.26 lib/ms/mzml/file_description.rb
mspire-0.6.25 lib/ms/mzml/file_description.rb
mspire-0.6.24 lib/ms/mzml/file_description.rb
mspire-0.6.22 lib/ms/mzml/file_description.rb
mspire-0.6.21 lib/ms/mzml/file_description.rb
mspire-0.6.20 lib/ms/mzml/file_description.rb
mspire-0.6.19 lib/ms/mzml/file_description.rb
mspire-0.6.18 lib/ms/mzml/file_description.rb
mspire-0.6.12 lib/ms/mzml/file_description.rb
mspire-0.6.11 lib/ms/mzml/file_description.rb
mspire-0.6.9 lib/ms/mzml/file_description.rb