Class: Mspire::Mzml::SourceFile
- Inherits:
-
Object
- Object
- Mspire::Mzml::SourceFile
- Extended by:
- List
- Includes:
- CV::Paramable
- Defined in:
- lib/mspire/mzml/source_file.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
(required) An identifier for this file.
-
#location ⇒ Object
(required) URI-formatted location where the file was retrieved.
-
#name ⇒ Object
(required) Name of the source file, without reference to location (either URI or local path).
Attributes included from CV::Paramable
#cv_params, #ref_param_groups, #user_params
Class Method Summary collapse
-
.[](path, opts = {}) ⇒ Object
expands the path and sets the name and location.
- .from_xml(xml, ref_hash) ⇒ Object
-
.uri_basename_and_path(file) ⇒ Object
takes a filename (with a relative or expanded path) and returns the uri basename and path suitable for mzml files.
Instance Method Summary collapse
-
#initialize(id = "sourcefile1", name = "mspire-simulated", location = 'file://') {|_self| ... } ⇒ SourceFile
constructor
A new instance of SourceFile.
- #to_xml(builder) ⇒ Object
Methods included from List
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 = "sourcefile1", name = "mspire-simulated", location = 'file://') {|_self| ... } ⇒ SourceFile
Returns a new instance of SourceFile.
35 36 37 38 39 |
# 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 |
Instance Attribute Details
#id ⇒ Object
(required) An identifier for this file.
12 13 14 |
# File 'lib/mspire/mzml/source_file.rb', line 12 def id @id end |
#location ⇒ Object
(required) URI-formatted location where the file was retrieved.
17 18 19 |
# File 'lib/mspire/mzml/source_file.rb', line 17 def location @location end |
#name ⇒ Object
(required) Name of the source file, without reference to location (either URI or local path).
15 16 17 |
# File 'lib/mspire/mzml/source_file.rb', line 15 def name @name end |
Class Method Details
.[](path, opts = {}) ⇒ Object
expands the path and sets the name and location. Sets the id to the basename.
21 22 23 24 |
# 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) ⇒ Object
48 49 50 |
# 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 |
.uri_basename_and_path(file) ⇒ Object
takes a filename (with a relative or expanded path) and returns the uri basename and path suitable for mzml files
28 29 30 31 32 33 |
# File 'lib/mspire/mzml/source_file.rb', line 28 def self.uri_basename_and_path(file) pathname = Pathname.new(file) dir = pathname..dirname.to_s dir = '/'+dir unless (dir[0] == '/') [pathname.basename, 'file://'+ dir] end |
Instance Method Details
#to_xml(builder) ⇒ Object
41 42 43 44 45 46 |
# 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 |