Class: Mspire::Mzml::IndexList

Inherits:
Array
  • Object
show all
Defined in:
lib/mspire/mzml/index_list.rb

Overview

A simple array of indices but #[] has been overloaded to find an index by name

index_list[0]  # the first index
index_list.map(&:names) # -> [:spectrum, :chromatogram] 
index_list[:spectrum]  # the spectrum index
index_list[:chromatogram]  # the chromatogram index

Instance Method Summary collapse

Methods inherited from Array

#in_groups

Instance Method Details

#[](int_or_symbol) ⇒ Mspire::Mzml::Index

Returns an index object.

Parameters:

  • an (Object)

    Integer (index number) or a Symbol (:spectrum or :chromatogram)

Returns:



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

def [](int_or_symbol)
  if int_or_symbol.is_a?(Integer)
    old_bracket_slice(int_or_symbol)
  else
    self.find {|index| index.name == int_or_symbol }
  end
end

#old_bracket_sliceObject



11
# File 'lib/mspire/mzml/index_list.rb', line 11

alias_method :old_bracket_slice, :'[]'