Sha256: 256a21cab5457e3fd18a987ecc74bf577de0b0a8b47b975b30874adae948cfc0

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

require 'mspire/cv/paramable'
require 'mspire/mzml/component'
require 'mspire/mzml/list'

module Mspire
  class Mzml
    class InstrumentConfiguration
      include Mspire::CV::Paramable
      extend Mspire::Mzml::List

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

      # a list of Source, Analyzer, Detector objects (optional)
      attr_accessor :components

      # a single software object associated with the instrument (optional)
      attr_accessor :software

      def initialize(id, components=[])
        @id, @components = id, components
        params_init
        yield(self) if block_given?
      end

      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

      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|
            Mspire::Mzml.const_get(component_n.name.capitalize).new.describe_self_from_xml!(component_n, link[:ref_hash])
          end
          next_n = next_n.next
        end
        if next_n && next_n.name == 'softwareRef'
          obj.software = link[:software_hash][next_n[:ref]]
        end
        obj
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mspire-0.8.5 lib/mspire/mzml/instrument_configuration.rb
mspire-0.8.4 lib/mspire/mzml/instrument_configuration.rb
mspire-0.8.3 lib/mspire/mzml/instrument_configuration.rb
mspire-0.8.2 lib/mspire/mzml/instrument_configuration.rb
mspire-0.8.1 lib/mspire/mzml/instrument_configuration.rb
mspire-0.8.0 lib/mspire/mzml/instrument_configuration.rb