class Mspire::Mzml::SourceFile
Attributes
id[RW]
(required) An identifier for this file.
location[RW]
(required) URI-formatted location where the file was retrieved.
name[RW]
(required) Name of the source file, without reference to location (either URI or local path).
Public Class Methods
[](path, opts={})
click to toggle source
expands the path and sets the name and location. Sets the id to the basename.
# File lib/mspire/mzml/source_file.rb, line 21 def self.[](path, opts={}) (name, path) = uri_basename_and_path(path) self.new(name, name, path) end
from_xml(xml, ref_hash)
click to toggle source
# File lib/mspire/mzml/source_file.rb, line 48 def self.from_xml(xml, ref_hash) self.new(xml[:id], xml[:name], xml[:location]).describe_self_from_xml!(xml, ref_hash) end
new(id="sourcefile1", name="mspire-simulated", location='file://') { |self| ... }
click to toggle source
# File lib/mspire/mzml/source_file.rb, line 35 def initialize(id="sourcefile1", name="mspire-simulated", location='file://') @id, @name, @location = id, name, location params_init yield(self) if block_given? end
uri_basename_and_path(file)
click to toggle source
takes a filename (with a relative or expanded path) and returns the uri basename and path suitable for mzml files
# File lib/mspire/mzml/source_file.rb, line 28 def self.uri_basename_and_path(file) pathname = Pathname.new(file) dir = pathname.expand_path.dirname.to_s dir = '/'+dir unless (dir[0] == '/') [pathname.basename, 'file://'+ dir] end
Public Instance Methods
to_xml(builder)
click to toggle source
Calls superclass method
Mspire::Paramable#to_xml
# File lib/mspire/mzml/source_file.rb, line 41 def to_xml(builder) builder.sourceFile( id: @id, name: @name, location: @location ) do |sf_n| super(sf_n) end builder end