Class: SciYAG::Backends::DataSource
- Inherits:
-
Object
- Object
- SciYAG::Backends::DataSource
- Defined in:
- lib/SciYAG/Backends/source.rb
Overview
A data source is a class containing raw data, most probably under the form of a list of Dvectors. It is the job of Representations to transform that source into a 2D or 3D set.
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
The list of the columns.
-
#columns_info ⇒ Object
readonly
A list of hashes of informations about the columns.
-
#informations ⇒ Object
Some informations about the source.
Instance Method Summary collapse
-
#add_column(col, name = nil, infos = {}) ⇒ Object
Add a column and its information to the list.
-
#auto_name(number) ⇒ Object
Automatic naming of the columns.
-
#initialize(*columns) ⇒ DataSource
constructor
Creates a datasource, and fills it with the columns columns.
Constructor Details
#initialize(*columns) ⇒ DataSource
Creates a datasource, and fills it with the columns columns. It is better however to use directly #add_column to fill the source with Data.
43 44 45 46 47 |
# File 'lib/SciYAG/Backends/source.rb', line 43 def initialize(*columns) @columns = [] @columns_info = [] @informations = {} end |
Instance Attribute Details
#columns ⇒ Object (readonly)
The list of the columns
28 29 30 |
# File 'lib/SciYAG/Backends/source.rb', line 28 def columns @columns end |
#columns_info ⇒ Object (readonly)
A list of hashes of informations about the columns
31 32 33 |
# File 'lib/SciYAG/Backends/source.rb', line 31 def columns_info @columns_info end |
#informations ⇒ Object
Some informations about the source. Different possibilities:
-
:filename, the name of the file from where the source is coming;
-
:dataset, the name of dataset, if applicable.
and so on…
38 39 40 |
# File 'lib/SciYAG/Backends/source.rb', line 38 def informations @informations end |
Instance Method Details
#add_column(col, name = nil, infos = {}) ⇒ Object
Add a column and its information to the list.
55 56 57 58 59 60 |
# File 'lib/SciYAG/Backends/source.rb', line 55 def add_column(col, name = nil, infos = {}) name = auto_name(col.length) unless name @columns << col infos[:name] = name @columns_info << infos end |
#auto_name(number) ⇒ Object
Automatic naming of the columns
50 51 52 |
# File 'lib/SciYAG/Backends/source.rb', line 50 def auto_name(number) return "$#{number}" end |