Class: Mspire::Mzml::Sample

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

Instance Attribute Summary collapse

Attributes included from 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 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) {|_self| ... } ⇒ Sample

Returns a new instance of Sample.

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
20
# File 'lib/mspire/mzml/sample.rb', line 16

def initialize(id)
  @id = id
  params_init
  yield(self) if block_given?
end

Instance Attribute Details

#idObject

A unique identifier across the samples with which to reference this sample description.



11
12
13
# File 'lib/mspire/mzml/sample.rb', line 11

def id
  @id
end

#nameObject

An optional name for the sample description, mostly intended as a quick mnemonic.



14
15
16
# File 'lib/mspire/mzml/sample.rb', line 14

def name
  @name
end

Class Method Details

.from_xml(xml, link) ⇒ Object



29
30
31
32
33
# File 'lib/mspire/mzml/sample.rb', line 29

def self.from_xml(xml, link)
  obj = self.new(xml[:id])
  obj.name = xml[:name]
  obj.describe_self_from_xml!(xml, link[:ref_hash])
end

Instance Method Details

#to_xml(builder) ⇒ Object



22
23
24
25
26
27
# File 'lib/mspire/mzml/sample.rb', line 22

def to_xml(builder)
  builder.sample( id: @id, name: @name ) do |sample_n|
    super(sample_n)
  end
  builder
end