Class: Mspire::Mzml::FileDescription
- Inherits:
-
Object
- Object
- Mspire::Mzml::FileDescription
- Defined in:
- lib/mspire/mzml/file_description.rb
Instance Attribute Summary collapse
-
#contacts ⇒ Object
zero to many (just listed in the singular, not enclosed in a list).
-
#file_content ⇒ Object
a summary of the different types of spectra, must be present.
-
#source_files ⇒ Object
may or may not be present.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_content = nil, source_files = [], contacts = []) {|_self| ... } ⇒ FileDescription
constructor
hands the user the object if given a block.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(file_content = nil, source_files = [], contacts = []) {|_self| ... } ⇒ FileDescription
hands the user the object if given a block
25 26 27 28 29 |
# 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 |
Instance Attribute Details
#contacts ⇒ Object
zero to many (just listed in the singular, not enclosed in a list)
<contact>
</contact>
<contact>
</contact>
22 23 24 |
# File 'lib/mspire/mzml/file_description.rb', line 22 def contacts @contacts end |
#file_content ⇒ Object
a summary of the different types of spectra, must be present
11 12 13 |
# File 'lib/mspire/mzml/file_description.rb', line 11 def file_content @file_content end |
#source_files ⇒ Object
may or may not be present
14 15 16 |
# File 'lib/mspire/mzml/file_description.rb', line 14 def source_files @source_files end |
Class Method Details
.from_xml(xml, link) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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 |
Instance Method Details
#to_xml(builder) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 |