Class: Mspire::Mzml::SourceFile
- Inherits:
-
Object
- Object
- Mspire::Mzml::SourceFile
- Extended by:
- List
- Includes:
- CV::Paramable
- Defined in:
- lib/mspire/mzml/source_file.rb
Constant Summary collapse
- DEFAULT_SOURCEFILE_ID =
'sourcefile1'
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.
-
.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://', opts = {params: []}, &block) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #to_xml(builder) ⇒ Object
Methods included from List
Methods included from CV::Paramable
#accessionable_params, #describe!, #describe_many!, #fetch, #fetch_by_accession, #param?, #param_by_accession, #params, #params?
Constructor Details
#initialize(id = "sourcefile1", name = "mspire-simulated", location = 'file://', opts = {params: []}, &block) ⇒ SourceFile
Returns a new instance of SourceFile.
34 35 36 37 38 |
# File 'lib/mspire/mzml/source_file.rb', line 34 def initialize(id="sourcefile1", name="mspire-simulated", location='file://', opts={params: []}, &block) @id, @name, @location = id, name, location super(opts) block.call(self) if block end |
Instance Attribute Details
#id ⇒ Object
(required) An identifier for this file.
13 14 15 |
# File 'lib/mspire/mzml/source_file.rb', line 13 def id @id end |
#location ⇒ Object
(required) URI-formatted location where the file was retrieved.
18 19 20 |
# File 'lib/mspire/mzml/source_file.rb', line 18 def location @location end |
#name ⇒ Object
(required) Name of the source file, without reference to location (either URI or local path).
16 17 18 |
# File 'lib/mspire/mzml/source_file.rb', line 16 def name @name end |
Class Method Details
.[](path, opts = {}) ⇒ Object
expands the path and sets the name and location
21 22 23 |
# File 'lib/mspire/mzml/source_file.rb', line 21 def self.[](path, opts={}) self.new DEFAULT_SOURCEFILE_ID, *uri_basename_and_path(path) 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
27 28 29 30 31 32 |
# File 'lib/mspire/mzml/source_file.rb', line 27 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
40 41 42 43 44 45 |
# File 'lib/mspire/mzml/source_file.rb', line 40 def to_xml(builder) builder.sourceFile( id: @id, name: @name, location: @location ) do |sf_n| super(sf_n) end builder end |