Module: BioTable::Indexer
- Defined in:
- lib/bio-table/indexer.rb
Class Method Summary collapse
-
.create_index(table, columns) ⇒ Object
Create an index (Hash) of column field contents, pointing to a TableRow.
- .make_key(row, columns) ⇒ Object
Class Method Details
.create_index(table, columns) ⇒ Object
Create an index (Hash) of column field contents, pointing to a TableRow
7 8 9 10 11 12 13 |
# File 'lib/bio-table/indexer.rb', line 7 def self.create_index table, columns idx = {} table.each do | row | idx[make_key(row,columns)] = row end idx end |
.make_key(row, columns) ⇒ Object
15 16 17 |
# File 'lib/bio-table/indexer.rb', line 15 def self.make_key row, columns columns.map { |i| row.all_fields[i] } end |