Class: Hyphy::DatasetCollection
- Inherits:
-
Object
- Object
- Hyphy::DatasetCollection
- Defined in:
- lib/hyphy/dataset_collection.rb
Defined Under Namespace
Classes: InvalidKeyException
Instance Attribute Summary collapse
-
#dataset_collection ⇒ Object
readonly
Returns the value of attribute dataset_collection.
Instance Method Summary collapse
- #counts_hash ⇒ Object
-
#initialize(dataset, key) ⇒ DatasetCollection
constructor
A new instance of DatasetCollection.
- #process_dataset ⇒ Object
Constructor Details
#initialize(dataset, key) ⇒ DatasetCollection
Returns a new instance of DatasetCollection.
7 8 9 10 11 12 13 |
# File 'lib/hyphy/dataset_collection.rb', line 7 def initialize(dataset, key) raise InvalidKeyException unless Hyphy::SQLStatement.method_defined?(key) @key = key @dataset = dataset @dataset_collection = {} end |
Instance Attribute Details
#dataset_collection ⇒ Object (readonly)
Returns the value of attribute dataset_collection.
5 6 7 |
# File 'lib/hyphy/dataset_collection.rb', line 5 def dataset_collection @dataset_collection end |
Instance Method Details
#counts_hash ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/hyphy/dataset_collection.rb', line 25 def counts_hash key_to_count = {} @dataset_collection.map do |key, dataset| key_to_count[key] = dataset.data.count end key_to_count end |
#process_dataset ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/hyphy/dataset_collection.rb', line 15 def process_dataset collection = Hash.new { |hash, key| hash[key] = [] } @dataset.data.each do |sql_statement| collection[sql_statement.send(@key)] << sql_statement end collection.each { |key, value| @dataset_collection[key] = Hyphy::Dataset.new(value) } end |