class Mspire::Mzml::InstrumentConfiguration

Attributes

components[RW]

a list of Source, Analyzer, Detector objects (optional)

id[RW]

(required) the id that this guy can be referenced from

software[RW]

a single software object associated with the instrument (optional)

Public Class Methods

from_xml(xml, link) click to toggle source
# File lib/mspire/mzml/instrument_configuration.rb, line 35
def self.from_xml(xml, link)
  obj = self.new(xml[:id])
  next_n = obj.describe_from_xml!(xml, link[:ref_hash])
  if next_n && (next_n.name == 'componentList')
    obj.components = next_n.children.map do |component_n|
      if component_n.is_a?(Nokogiri::XML::Text)
        # TODO: this is a fix for when there is an empty component list but
        # Nokogiri returns a text node.  Really this needs to be fixed
        # in our xml writer!
        nil
      else
        Mspire::Mzml.const_get(component_n.name.capitalize).new.describe_self_from_xml!(component_n, link[:ref_hash])
      end
    end.compact
    next_n = next_n.next
  end
  if next_n && next_n.name == 'softwareRef'
    obj.software = link[:software_hash][next_n[:ref]]
  end
  obj
end
new(id, components=[]) { |self| ... } click to toggle source
# File lib/mspire/mzml/instrument_configuration.rb, line 20
def initialize(id, components=[])
  @id, @components = id, components
  params_init
  yield(self) if block_given?
end

Public Instance Methods

to_xml(builder) click to toggle source
Calls superclass method Mspire::Paramable#to_xml
# File lib/mspire/mzml/instrument_configuration.rb, line 26
def to_xml(builder)
  builder.instrumentConfiguration(id: @id) do |inst_conf_n|
    super(builder)
    Mspire::Mzml::Component.list_xml(components, inst_conf_n)
    inst_conf_n.softwareRef(ref: @software.id) if @software
  end
  builder
end