Class: Mspire::Mzml::FileDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/mspire/mzml/file_description.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_content = nil, source_files = [], contacts = [], &block) ⇒ FileDescription

hands the user the object if given a block



24
25
26
27
28
# File 'lib/mspire/mzml/file_description.rb', line 24

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

Instance Attribute Details

#contactsObject

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

<contact>
</contact>
<contact>
</contact>


21
22
23
# File 'lib/mspire/mzml/file_description.rb', line 21

def contacts
  @contacts
end

#file_contentObject

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



10
11
12
# File 'lib/mspire/mzml/file_description.rb', line 10

def file_content
  @file_content
end

#source_filesObject

may or may not be present



13
14
15
# File 'lib/mspire/mzml/file_description.rb', line 13

def source_files
  @source_files
end

Class Method Details

.from_xml(xml) ⇒ Object



30
31
32
# File 'lib/mspire/mzml/file_description.rb', line 30

def self.from_xml(xml)
  self.new
end

Instance Method Details

#to_xml(builder) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mspire/mzml/file_description.rb', line 34

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