Class: Mspire::Mzml::InstrumentConfiguration

Inherits:
Object
  • Object
show all
Extended by:
List
Includes:
CV::Paramable
Defined in:
lib/mspire/mzml/instrument_configuration.rb

Instance Attribute Summary collapse

Attributes included from CV::Paramable

#cv_params, #ref_param_groups, #user_params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from List

list_xml, list_xml_element

Methods included from CV::Paramable

#accessionable_params, #describe!, #describe_from_xml!, #describe_many!, #describe_self_from_xml!, #each_accessionable_param, #each_param, #fetch, #fetch_by_accession, #param?, #param_by_accession, #params, #params?, #reject!, #replace!, #replace_many!

Constructor Details

#initialize(id, components = []) {|_self| ... } ⇒ InstrumentConfiguration

Returns a new instance of InstrumentConfiguration.

Yields:

  • (_self)

Yield Parameters:



20
21
22
23
24
# 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

Instance Attribute Details

#componentsObject

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



15
16
17
# File 'lib/mspire/mzml/instrument_configuration.rb', line 15

def components
  @components
end

#idObject

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



12
13
14
# File 'lib/mspire/mzml/instrument_configuration.rb', line 12

def id
  @id
end

#softwareObject

a single software object associated with the instrument (optional)



18
19
20
# File 'lib/mspire/mzml/instrument_configuration.rb', line 18

def software
  @software
end

Class Method Details

.from_xml(xml, link) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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|
      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

Instance Method Details

#to_xml(builder) ⇒ Object



26
27
28
29
30
31
32
33
# 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