class Mspire::Mzml::FileDescription

Attributes

contacts[RW]

zero to many (just listed in the singular, not enclosed in a list)

<contact>
</contact>
<contact>
</contact>
file_content[RW]

a summary of the different types of spectra, must be present

source_files[RW]

may or may not be present

Public Class Methods

from_xml(xml, link) click to toggle source
# File lib/mspire/mzml/file_description.rb, line 31
def self.from_xml(xml, link)
  ref_hash = link[:ref_hash]
  file_content_n = xml.child
  obj = self.new( Mspire::Mzml::FileContent.new.describe_self_from_xml!(file_content_n, ref_hash) )

  return obj unless next_n = file_content_n.next

  if next_n.name == 'sourceFileList'
    obj.source_files = next_n.children.map do |source_file_n|
      Mspire::Mzml::SourceFile.from_xml(source_file_n, ref_hash)
    end
    return obj unless next_n = next_n.next
  end

  loop do
    obj.contacts << Mspire::Mzml::Contact.from_xml(contact_n, ref_hash)
    break unless contact_n = contact_n.next
  end
  obj
end
new(file_content=nil, source_files=[], contacts=[]) { |self| ... } click to toggle source

hands the user the object if given a block

# File lib/mspire/mzml/file_description.rb, line 25
def initialize(file_content=nil, source_files=[], contacts=[])
  @file_content, @source_files, @contacts = file_content, source_files, contacts
  yield(self) if block_given?
  #raise ArgumentError, "FileDescription must have file_content" unless @file_content
end

Public Instance Methods

to_xml(builder) click to toggle source
# File lib/mspire/mzml/file_description.rb, line 52
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